Documents

Document Manage Async

POST
/documents/document/manage/async

This endpoint allows you to initiate asynchronous document management operations, such as copying, moving, deleting (currently only supports OneDrive), or converting documents, across platforms like Storage, Salesforce, and OneDrive, without modifying their internal content. Unlike the synchronous version, it returns immediately and processes the requested operation in the background. The result can be tracked or received via promise or callback, depending on your integration setup. This approach is ideal for handling large files, slower systems, or when non-blocking execution is preferred.

Authorization

AuthorizationBearer <token>

JWT token to authenticate the request.

In: header

X-Api-Key<token>

API key, sent as a request header.

In: header

Header Parameters

X-Client-Authorization?string

This does not authenticate the async request itself — that's Authorization. It authenticates Doctavian's callback to your service once the async result is ready.

Generate it by calling POST /common/client/token with the claims below as plain JSON. That endpoint signs and encrypts the payload for you and returns the ready-to-use token in result.data.token — you never construct or sign this token yourself.

Required claims: sub (the access token your callback endpoint accepts from Doctavian), iss (base URL of the service receiving the callback), dest (the callback route, e.g. /temp/callback — combined with iss to form the full callback URL). Optional claims: oid, client_id, full_name, email, locale, zoneinfo. You don't need to set iat or exp — the token endpoint handles timing.

iss and dest cannot resolve back to Doctavian's own API — that combination is rejected to prevent a callback loop.

If this header is missing on an async request, the response is 400 X_CLIENT_AUTH_ERROR ("header is missing for async operations").

Request Body

application/json

externalContext A contextual reference used to link the document generation request to an external system, process, or transaction. Often used for traceability or auditing purposes.


sourceDocument Identifies the input document and its properties, serving as the starting point for file operations like copying to a new location, moving with deletion, deleting outright, or converting to a different format.

sourceDocument.options Fine-tunes the loading process for the source document to meet specific requirements, such as retaining formatting or handling special features during operations like copying or conversion.


targetDocument Defines the properties of the output document resulting from the file operation (e.g., the destination for Copy, Move, or Convert operations). It specifies the document's metadata, format, delivery method, storage location, and processing options, determining how the processed document is saved and managed. This node is omitted for Delete operations, as no output document is generated.

targetDocument.options.salesforce Specifies how the document will be stored or associated with records in Salesforce. Includes fields such as fileId, fileType, fileParentId, and ownerId.

targetDocument.options.onedrive Specifies how the document will be shared or stored via Microsoft OneDrive. Includes permission settings like anonymous access, edit/view rights, and user-specific sharing.

document.options.googledrive Specifies how the document will be shared or stored via Google Drive. Includes permission settings like anonymous access, edit/view rights, and user-specific sharing.

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/documents/document/manage/async" \  -H "Content-Type: application/json" \  -d '{    "externalContext": {      "id": "req-2026-0007421"    },    "sourceDocument": {      "urn": "e3b0c442-98fc-4e1a-8a3d-2c1b5f6e9a70",      "fileFormat": "docx",      "loadMethod": "Storage",      "remove": "none",      "options": {        "docxLoadOptions": "{ \\"PreserveUnsupportedFeatures\\": true }"      }    },    "targetDocument": {      "name": "Q3 Sales Report - Archived",      "fileFormat": "docx",      "deliveryMethod": "Storage",      "path": "root",      "options": {        "pdfSaveOptions": "{ \\"ConformanceLevel\\": \\"PdfA3a\\", \\"Version\\": \\"PDF_1_7\\", \\"ImageDpi\\": 750 }",        "docxSaveOptions": "{}",        "salesforce": {          "networkId": "0DMXYZ0000000AAAA",          "fileId": "069AZ0000004CvXYAW",          "fileType": "File",          "fileParentId": "0013P00000MvR7oQAF",          "ownerId": "0053P00000MvR7oQAF"        },        "onedrive": {          "viewAnonymous": true,          "editAnonymous": true,          "editUsers": [            "user@example.com"          ],          "viewUsers": [            "user@example.com"          ]        }      }    },    "data": {      "embedded": "key:value"    }  }'
{  "result": {    "statusCode": 201,    "message": "Created",    "data": {      "document": {        "deliveryMethod": "Storage",        "name": "Q3 Sales Report - Archived",        "fileFormat": "docx",        "urn": "c72f4a1e-9d3b-4c5f-8a6e-1b2c3d4e5f6a"      }    }  },  "consumption": [    {      "dimension": "pages-managed",      "value": 4    },    {      "dimension": "documents-managed",      "value": 1    }  ],  "externalContext": {    "actionRequestId": "req-2026-0007421"  },  "origin": "POST https://api.doctavian.com/v1/documents/document/manage/async",  "dateTime": "2026-07-14T09:30:00.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "b62f1c86403f3649e9e8cfe197d5c192"}
{  "error": {    "statusCode": 400,    "message": "Bad Request",    "innerErrors": [      {        "code": "TEMPLATE_NOT_FOUND",        "message": "The specified template could not be located.",        "userMessage": "We couldn't generate your document. Please check the template reference and try again."      }    ]  },  "externalContext": {    "actionRequestId": "req-2026-0007421"  },  "origin": "POST https://api.doctavian.com/v1/documents/document/manage/async",  "dateTime": "2026-07-14T09:30:00.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "2b7fec929ef296cfddd7c8408fc55255"}