Doctavian can call your service instead of making you poll. This guide covers both kinds of callback: what triggers them, how to set them up, what the bodies look like, and what to do when one arrives — or doesn't.
| Async document results | Envelope status callbacks | |
|---|---|---|
| Triggered by | POST /documents/document/generate/async, /manage/async and /merge/async | POST /signatures/envelope/{envelopeId}/send |
X-Client-Authorization | Required | Optional — without it no callbacks are made |
| How many | One, when the operation finishes | One when the envelope is sent, then one each time the envelope's status or a recipient's status changes |
Both kinds are set up the same way: you generate a client token once, send it in the X-Client-Authorization header, and Doctavian POSTs to the URL the token names.
Make sure you have:
Authorization bearer token and your API key (x-api-key) — see AuthenticationPOST requests with a JSON bodyGenerate the X-Client-Authorization value once with POST /common/client/token, as described in Client Header. Set connector_id to your connector's id, and iss + dest to your callback endpoint's URL — for example https://your-system.example.com + /doctavian/callback. Keep the returned result.data.clientToken.token; it can be reused.
POSTs a JSON body to iss + dest — in the example above, https://your-system.example.com/doctavian/callback.connector_id. Set those credentials to whatever your endpoint expects.2xx status.One endpoint can serve both kinds of callback, or you can generate one token per route. A single endpoint tells the bodies apart by their top-level properties: an async document result has result or error; an envelope status callback has envelope.
Send result.data.clientToken.token unchanged as X-Client-Authorization. On an async document operation, send it with the same body as the synchronous operation:
POST https://api.doctavian.com/v1/documents/document/generate/async
Authorization: Bearer <token>
x-api-key: <api-key>
X-Client-Authorization: <result.data.clientToken.token>
Content-Type: application/json
{
"externalContext": { "orderId": "SO-2026-0042" },
"template": {
"urn": "9f86d081-884c-4d30-8934-9c1e6cbcb9f5",
"loadMethod": "Storage",
"fileFormat": "docx"
},
"data": {
"urn": "a4f8c9d2-6b3e-4f1a-9c7d-2e5b8a1f4d6c",
"loadMethod": "Storage"
},
"document": {
"name": "INV-2026-000123",
"fileFormat": "pdf",
"deliveryMethod": "Storage",
"path": "root"
}
}The response is HTTP 200 with an empty body as soon as the request is queued. The outcome arrives at your endpoint.
On envelope send, the header is the only way to turn callbacks on:
POST https://api.doctavian.com/v1/signatures/envelope/61914d53-50ec-44a9-a64f-ed473f2c82cf/send
Authorization: Bearer <token>
x-api-key: <api-key>
X-Client-Authorization: <result.data.clientToken.token>
Content-Type: application/json
{}An envelope can be sent only once, so the header must go on that one send call — callbacks can't be switched on for an envelope that is already In Progress.
When an async generate, manage or merge finishes, Doctavian sends one callback. Tell success from failure by whether result or error is present.
The body is what the synchronous operation returns on success. The fields you act on are result.data.document and your externalContext:
{
"result": {
"statusCode": 201,
"message": "Created",
"data": {
"document": {
"deliveryMethod": "Storage",
"name": "INV-2026-000123",
"fileFormat": "pdf",
"urn": "c72f4a1e-9d3b-4c5f-8a6e-1b2c3d4e5f6a"
}
}
},
"externalContext": { "orderId": "SO-2026-0042" },
"operationId": "c1d7e2a94b3f46085a9e1c7d2b4f8e30",
...
}The result.data of each operation is described in Generate Document, Convert, Copy and Move Documents and Merge Documents.
The body is the standard error envelope. Unlike the synchronous operation, no trailing GENERATE_FUNCTION_FAILED, MANAGE_FUNCTION_FAILED or MERGE_FUNCTION_FAILED entry is added, so the first entry in error.innerErrors is the cause:
{
"error": {
"statusCode": 400,
"message": "Bad Request",
"innerErrors": [
{
"code": "INVALID_LOAD_METHOD_SPECIFIED",
"message": "The specified load method Storages is invalid or not supported. Please verify the method and try again.",
...
}
]
},
"externalContext": { "orderId": "SO-2026-0042" },
"operationId": "c1d7e2a94b3f46085a9e1c7d2b4f8e30",
...
}Usage limits are checked when the request is processed, not when it is queued, so a reached limit arrives here as a failure callback with LIMIT_BREACH, not as an HTTP 403 from the async endpoint. See Error Handling for reading the error envelope.
For an envelope sent with the header, Doctavian sends a callback:
envelope.status In Progress;Completed, Declined, Expired, Canceled or Failed.The body is an EnvelopeStatusCallback. It is not a response to any call, so it has no result wrapper and no operationId:
{
"envelope": {
"id": "61914d53-50ec-44a9-a64f-ed473f2c82cf",
"status": "Completed",
"uri": "https://api.doctavian.com/v1/signatures/envelope/61914d53-50ec-44a9-a64f-ed473f2c82cf/get",
"ownerEmail": "contracts@worldindustries.com"
},
"documents": [
{
"id": "eff65b7a-3b81-4e41-8b2e-70ed15b645bf",
"name": "NDA Agreement",
"externalContext": { "contractId": "NDA-2026-0187" },
...
}
],
"recipients": [
{
"id": "d66078c4-96f1-4f60-8a96-f1fe00df25e6",
"name": "Jane Smith",
"email": "jane.smith@example.com",
"status": "Completed",
"externalContext": { "contactId": "C-88213" }
}
],
"fields": [
{
"documentId": "eff65b7a-3b81-4e41-8b2e-70ed15b645bf",
"type": "text",
"name": "company_name",
"recipientId": "d66078c4-96f1-4f60-8a96-f1fe00df25e6",
"value": "Acme Ltd"
}
],
"externalContext": { "crmDealId": "D-20931" },
...
}The fields you act on:
envelope.id and envelope.status: which envelope, and where it stands. envelope.uri links to the full envelope.documents[].id: what you pass to the envelope document download once the envelope is Completed.recipients[].status: where each recipient stands — see Envelope Lifecycle.fields[].value: what each recipient entered.externalContext on the root, documents and recipients: your own ids, stored with the envelope.Both kinds of callback carry your externalContext back unchanged, but it comes from different places:
externalContext from the body of the async call. Put your own job or order id there on every async request. The async call returns an empty body, so externalContext is the only link between the request and its callback.envelope.externalContext, and the externalContext on each document and recipient, as set on POST /signatures/envelope/create or the last update. The request-level externalContext you send on send does not appear in callbacks. envelope.id also identifies the callback directly.An update to a draft envelope replaces the whole draft, so leaving
envelope.externalContextout clears it. Set it on every update if you rely on it in callbacks.
envelope.uri.Completed, download each signed document by its documents[].id, and the audit trail PDF if you keep it:GET https://api.doctavian.com/v1/signatures/envelope/61914d53-50ec-44a9-a64f-ed473f2c82cf/document/eff65b7a-3b81-4e41-8b2e-70ed15b645bf/download
Authorization: Bearer <token>
x-api-key: <api-key>GET https://api.doctavian.com/v1/signatures/envelope/61914d53-50ec-44a9-a64f-ed473f2c82cf/audit/download
Authorization: Bearer <token>
x-api-key: <api-key>Both return raw bytes with no file name, so name the files yourself — for a document, use documents[].name.
The final documents and the audit PDF are processed in the background right after the last signature. A call made straight away on the
Completedcallback can fail for a short time: the document download and envelope get return409ENVELOPE_DOCUMENTS_PROCESSING, and the audit trail download returns500FILE_NOT_EXISTS_IN_STORAGE. Retry shortly.
See Documents and Audit Trail.
result or error, then match the body to your request with externalContext.Storage delivery, download the file by result.data.document.urn with GET /documents/document/{urn}/download within 24 hours — Storage keeps files for 24 hours. For a drive delivery, the file is already on the drive at result.data.document.uri.error.innerErrors[0].code and send a new request. If the request used a Storage template, data file or source, it may already have been consumed — upload it again first.operationId (and any eventId) for support.Several mistakes produce no callback and no error. Check these first:
connector_id that names no existing connector, or an iss + dest that doesn't reach your endpoint, still produces a token and an accepted request, but delivery fails. See Client Header.400. It was rejected before it was queued, so no callback follows. Read the error in the response.X-Client-Authorization. No callbacks are made for it, and they can't be added later.Each callback is delivered once. There is no redelivery: if your endpoint is down, rejects the connector's credentials or doesn't return a
2xx, that callback is lost. Keep the polling fallback below for anything you must not miss.
Envelopes can always be polled. GET /signatures/envelope/{envelopeId}/get returns everything a status callback carries, and more. Use it as a fallback when a callback is overdue, or instead of callbacks altogether.
GET https://api.doctavian.com/v1/signatures/envelope/61914d53-50ec-44a9-a64f-ed473f2c82cf/get
Authorization: Bearer <token>
x-api-key: <api-key>Async document operations keep no record: the callback is the only report of the outcome, and there is nothing to poll. If you can't receive callbacks:
GET /documents/request/{documentRequestId}/get until its status is Completed or Failed. See Handle Async Generation.iss + dest is your endpoint's URL.2xx.result.data.clientToken.token is sent unchanged as X-Client-Authorization.externalContext; every envelope stores externalContext on the envelope, documents and recipients.Completed callback retry on 409 ENVELOPE_DOCUMENTS_PROCESSING and 500 FILE_NOT_EXISTS_IN_STORAGE.