Synchronous operations hold the connection open until the file is ready. When that is too long, or your integration is event-driven, Doctavian offers two ways to work in the background:
| Async operations with a callback | Document Requests | |
|---|---|---|
| Endpoints | POST /documents/document/generate/async, /manage/async, /merge/async | POST /documents/request/create, then GET /documents/request/{id}/get |
| Input | The same body as the synchronous operation | Saved template, data source and (optionally) Configuration records |
| Result delivery | Doctavian POSTs the result to your callback URL | You poll the request until it is Completed or Failed |
| Extra header | x-client-authorization — required | None |
| Record kept | No — the callback is the only report | Yes — the request, its status and the resulting document record |
This guide assumes you have run the synchronous flow in Generate Document.
Send the same body as the synchronous operation to its /async twin, with an x-client-authorization header:
externalContext you can match on later, such as your order or job id. The response is HTTP 200 with an empty body as soon as the request is queued — it does not mean the document was generated. A 400 means it was rejected before it was queued, so no callback follows; a missing header returns X_CLIENT_AUTH_ERROR.POSTs the synchronous success envelope, or an error envelope, to your endpoint with your externalContext echoed back. Receive Callbacks shows a full request, both bodies and how to handle them.POST /documents/document/manage/async and POST /documents/document/merge/async work the same way: same body as the synchronous operation, an empty 200, and the synchronous success envelope or an error envelope at your callback. See Convert, Copy and Move Documents and Merge Documents for the request bodies.
A Document Request needs no callback endpoint: the request is stored, generation runs in the background, and you read its status as it moves from New through Processing to Completed or Failed. See Document Requests for what a request is and its status lifecycle.
POST /documents/request/create. Keep result.data.documentRequest.id.GET /documents/request/{documentRequestId}/get every few seconds until status is Completed or Failed.Completed, read the document record with GET /documents/document/{documentId}/get. Its urn is the file's id.Storage, call GET /documents/document/{urn}/download within 24 hours. For OneDrive or GoogleDrive, the file is on the drive: the record's url links to it and its urn is the drive's file id.Failed, read errorMessage, fix the cause, and create a new request — a failed request is not retried.Generate Document, Part 2, shows each of these calls with request and response bodies.
GET /documents/request/list pages through the subscription's requests, newest first. Filter it instead of polling requests one by one. filter is a URL-encoded JSON array; decoded, a filter for failed requests looks like this:
[{"key":"Filter1","column":"Status","type":"string","condition":"EQUAL","value":"Failed"}]GET https://api.doctavian.com/v1/documents/request/list?top=25&skip=0&orderby=CreatedDate|DESC&filter=%5B%7B%22key%22%3A%22Filter1%22%2C%22column%22%3A%22Status%22%2C%22type%22%3A%22string%22%2C%22condition%22%3A%22EQUAL%22%2C%22value%22%3A%22Failed%22%7D%5D
Authorization: Bearer <token>
x-api-key: <api-key>The page is in result.data.documentRequests. See the API Reference for the filterable columns and paging fields.
Failed with FILE_MISSING_FROM_STORAGE. Upload the file again and update the record's urn first — see Retention and single use.Failed. A fileFormat/deliveryMethod pair that can't be delivered, or a locale outside the supported list, is accepted at create time and ends the request in Failed.PUT /documents/request/{id}/update is a full replacement of the stored fields; it does not run generation again or change a document already produced.DELETE /documents/request/{id}/delete removes the request only; the document record and file it produced are kept.200 from an async operation means, and where its result arrivesNew, Processing, Completed and Failed, and how to get from a completed request to the file