Skip to content
DocsMenu

Publish a document version

View as Markdown

Open this page inChatGPTClaudeCursor

In the Esign Comply API, POST /v1/documents/{id}/versions publishes an immutable version of a document from its text or PDF, or from its hash alone, and returns the version with its two hashes. Call it from your server when the text is final, since a published version cannot be edited or deleted.

POST /v1/documents/{id}/versions · API version 2026-11-21

Authentication

Send a secret key in the Authorization header: Bearer $ESIGNCOMPLY_API_KEY. The key needs full_access or recording_access permission. Test keys and live keys both work, and each reads and writes the objects of its own environment. Call it from your server: a secret key never goes to a browser. Keys and permissions are described under Authentication.

Request example

cURL

curl https://esigncomply.com/v1/documents/doc_8Hq2/versions \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: publish-doc_8Hq2-2026-11-21" \
  -d '{
    "version_label": "2026-11-21",
    "content": {
      "format": "markdown",
      "text": "# Terms of Service\n\nThese terms govern your use of the Acme service.\n\n1. You may use the service for lawful purposes.\n2. We may update these terms. We ask you to accept material changes.\n"
    },
    "material_change": true
  }'

Node SDK

import { EsignComply } from "esigncomply";

const esc = new EsignComply(process.env.ESIGNCOMPLY_API_KEY);

const { data, error } = await esc.documents.versions.create(
  "doc_8Hq2",
  {
    version_label: "2026-11-21",
    content: {
      format: "markdown",
      text: "# Terms of Service\n\nThese terms govern your use of the Acme service.\n\n1. You may use the service for lawful purposes.\n2. We may update these terms. We ask you to accept material changes.\n",
    },
    material_change: true,
  },
  { idempotencyKey: "publish-doc_8Hq2-2026-11-21" },
);

The two samples send the same Idempotency-Key with bodies that differ in whitespace. Run one of them, or change the key: the same key with different bytes in the body answers 409 idempotency_conflict.

This request ran against the API on November 26, 2026, and the response below is what came back. IDs are example values, and long values are shortened with ....

What it does

Publishes an immutable version and returns its hashes. Publish when the text is final: there is no endpoint that edits or deletes a version. To change the text, publish a new version_label.

Parameters

Name In Type Required Description
id path string Yes ID of the document.

Body fields

Field Type Required Description
version_label string, 1 to 64 characters Yes Your label for the version, for example a date. One version per label and language.
language string, 2 to 16 characters No Language code. Default en. Stored in lower case.
effective_at RFC 3339 timestamp No When the version starts to resolve as current. Default: now.
content object Yes See "Content formats" below.
material_change boolean No Default false. true leaves earlier acceptances outstanding (see Re-acceptance).
summary_of_changes string, up to 2,000 characters No Plain summary you can show on a re-acceptance screen.

Headers: Idempotency-Key (optional, up to 255 characters) and Esign-Comply-Version (optional, a dated API version). See API conventions.

Response

201 Created with a DocumentVersion object.

{
  "object": "document_version",
  "id": "dv_3kT9",
  "document_id": "doc_8Hq2",
  "livemode": false,
  "version_label": "2026-11-21",
  "language": "en",
  "format": "markdown",
  "content_hash": "sha256:4e712fcc...",
  "render_hash": "sha256:56dbea58...",
  "size": 187,
  "material_change": true,
  "summary_of_changes": null,
  "effective_at": "2026-11-26T00:15:41.723Z",
  "published_at": "2026-11-26T00:15:41.724Z",
  "warnings": []
}

Response fields

Field Type Description
object string
id string
document_id string
livemode boolean
version_label string
language string
format string markdown, html, text, pdf or hash_only.
content_hash string SHA-256 of the exact stored bytes. For hash_only: the hash you registered.
render_hash string SHA-256 of the normalized visible text; what the browser SDK compares. null for a PDF, and for hash_only without render_sha256.
size integer
material_change boolean
summary_of_changes string
effective_at datetime
published_at datetime
warnings array of string

Content formats

content.format Other fields Notes
markdown text Rendered to sanitized HTML with GitHub-flavored Markdown.
html text Sanitized on receipt. If anything was removed, the response carries the warning html_sanitized and the hashes cover the sanitized text.
text text Plain text. Blank lines become paragraphs.
pdf data_base64 The file, base64-encoded. It must start with %PDF-. render_hash is null for PDFs.
hash_only sha256, optional render_sha256 No content is uploaded. sha256 is the SHA-256 of the file you keep, in lower-case hexadecimal, and becomes content_hash. The response carries the warning hash_only_customer_keeps_copy. See Hash-only registration.

Size limits: text content up to 4 MB, PDF files up to 10 MB, and the whole request body up to 4.4 MB. Because the PDF travels base64-encoded inside the JSON body, a PDF of roughly 3.3 MB is the practical limit in one request.

What publishing does

  • Stores the exact bytes and computes both hashes (see "Hashes" below). For hash_only it stores the hash you sent and no bytes.
  • Sends the document.version_published webhook.
  • With material_change: true, sends signer.reacceptance_required for each signer who has a record on an earlier version of the document. See Webhooks.

Errors

Code HTTP When
invalid_request 400 A required field is missing, content.text is empty, effective_at is not a timestamp, data_base64 is not a PDF, or content.sha256 is not a SHA-256 in lower-case hexadecimal. param names the field.
not_found 404 The document does not exist in this domain and environment.
idempotency_conflict 409 A version with this version_label and language already exists for the document (param: "version_label"), or the Idempotency-Key was reused with a different body.
file_too_large 422 Text over 4 MB or a PDF over 10 MB.

Like every call made with a secret key, it can also return missing_api_key, invalid_api_key, domain_not_verified, insufficient_permission, region_mismatch, rate_limit_exceeded and internal_error.

Every error has the same body: error.type, error.code, error.message, error.doc_url and error.request_id. See Errors.

Questions about POST /v1/documents/{id}/versions

Which credential does POST /v1/documents/{id}/versions need?

A secret key with full_access or recording_access permission. Send it as a Bearer token in the Authorization header, from your server only. A session client token is refused with insufficient_permission.

Does POST /v1/documents/{id}/versions work with a test key?

Yes. It works with test keys and live keys. A test key reads and writes test objects only, and a live key works once the domain is verified.

Does POST /v1/documents/{id}/versions count as a signature event?

No. A signature event is counted when a live record is written, by completing a session or by submitting a deferred acceptance. This call writes no record.

Is POST /v1/documents/{id}/versions idempotent?

Yes, with an Idempotency-Key header of up to 255 characters. A repeat with the same key and the same bytes in the body returns the original response, with the header Idempotent-Replayed: true. The same key with a different body answers 409 idempotency_conflict.

What is the rate limit for POST /v1/documents/{id}/versions?

The limit is counted for each key and depends on the plan: 2 requests per second on Free, 10 on Starter, 50 on Unlimited and 100 on Enterprise. Past the limit the API answers 429 rate_limit_exceeded with a Retry-After header.

Does the Node SDK have a method for POST /v1/documents/{id}/versions?

Yes: esc.documents.versions.create() in the esigncomply package. It resolves to { data, error } and does not throw.

Last updated · API version 2026-11-21