Document Generate Async
This endpoint allows you to initiate an asynchronous document generation request. Similar to the Documents Generate endpoint, it enables you to generate documents (e.g. PDF, DOCX, XLSX) by specifying a template, supplying structured data, and configuring output options such as format, storage location, and delivery method. Unlike the synchronous variant, this endpoint immediately returns control to the caller and processes the document generation in the background, returning a response via a callback, promise, depending on your integration setup once the document is ready. This endpoint is useful when generating complex documents that may require longer processing times or when you prefer non-blocking operations.
JWT token to authenticate the request.
In: header
API key, sent as a request header.
In: header
Header Parameters
Email of the user who starts the process, needed for GAS script processing
"jane.doe@example.com"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.
template Defines the primary document template to be used for generating the document. It includes the template’s metadata, source, file format, and any related templates used during processing.
template.options Provides additional configuration for how the template is loaded or processed (e.g., preserving unsupported features or applying file-specific handling options).
template.relatedItems An array of additional templates associated with the primary template. These may be appended or merged during document generation.
data Defines the source of data and variables that populate the template's placeholders or fields. It includes the method of data retrieval (e.g., from storage, Salesforce, OneDrive) and any static or dynamic content used in the final document.
data.variables
List of reusable name–value pairs injected into the data. Useful for passing static values, global variables, GraphQL expressions, or field formulas.
Note: This section is should be reviewed by Tomislav and Ivan A.
data.embedded An optional string providing inline key–value metadata pairs that may be embedded in the output file (e.g., in a PDF's metadata section).
document Defines the configuration and metadata of the final generated document, including its name, locale, format, timezone, delivery method, and storage destination.
document.options.salesforce
Specifies how the document will be stored or associated with records in Salesforce. Includes fields such as fileId, fileType, fileParentId, and ownerId.
document.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/generate/async" \ -H "Content-Type: application/json" \ -d '{ "externalContext": { "id": "req-2026-0007421" }, "template": { "name": "Standard Invoice", "urn": "9f86d081-884c-4d30-8934-9c1e6cbcb9f5", "fileFormat": "docx", "loadMethod": "Storage", "options": { "docxLoadOptions": "{ \\"PreserveUnsupportedFeatures\\": true }" }, "relatedItems": [ { "name": "Invoice Terms Addendum", "urn": "4b1e2f3a-5c6d-47e8-9a0b-1c2d3e4f5a6b", "fileFormat": "docx", "loadMethod": "Storage" } ] }, "data": { "loadMethod": "Storage", "urn": "a4f8c9d2-6b3e-4f1a-9c7d-2e5b8a1f4d6c", "variables": [ { "name": "createdDate", "value": "{!$now()}", "type": "fieldExpression" }, { "name": "requestId", "value": "{!requestId}", "type": "graphql" }, { "name": "customerName", "value": "Jane Doe", "type": "global" } ], "query": "{\\"query\\":\\"{Account {Name Description Owner.Username Id Opportunities {StageName OpportunityLineItems {Name}} Contacts {Id}}}\\"}", "embedded": "key:value" }, "document": { "timezone": "(GMT+00:00) Greenwich Mean Time (Europe/Dublin)", "locale": "en_IE_EURO", "name": "Q3 Sales Report", "fileFormat": "docx", "deliveryMethod": "Storage", "path": "root", "options": { "pdfSaveOptions": "{ \\"ConformanceLevel\\": \\"PdfA3a\\", \\"Version\\": \\"PDF_1_7\\", \\"ImageDpi\\": 750 }", "docxSaveOptions": "{}", "salesforce": { "fileId": "069AZ0000004CvXYAW", "fileType": "File", "fileParentId": "0013P00000MvR7oQAF", "ownerId": "0053P00000MvR7oQAF" }, "onedrive": { "viewAnonymous": true, "editAnonymous": true, "editUsers": [ "user@example.com" ], "viewUsers": [ "user@example.com" ] }, "googleDrive": { "viewAnonymous": true, "editAnonymous": true, "editUsers": [ "user@example.com" ], "viewUsers": [ "user@example.com" ] }, "googleGenerate": { "nativeMergeEnabled": true, "nativeImageMergeEnabled": true } } } }'{ "result": { "statusCode": "201", "message": "Created", "data": { "document": { "deliveryMethod": "Storage", "name": "Q3 Sales Report", "fileFormat": "docx", "urn": "c72f4a1e-9d3b-4c5f-8a6e-1b2c3d4e5f6a:Q3 Sales Report.docx" } } }, "consumption": [ { "dimension": "pages-generated", "value": 4 }, { "dimension": "documents-generated", "value": 1 } ], "externalContext": { "actionRequestId": "req-2026-0007421" }, "origin": "https://app.example.com", "dateTime": "2026-07-14T09:30:00.0000000+00:00", "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "operationId": "0HN7GK9M4T2R5"}{ "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.", "eventId": "a1b2c3d4" } ], "externalErrors": [] }, "externalContext": { "actionRequestId": "req-2026-0007421" }, "origin": "https://app.example.com", "dateTime": "2026-07-14T09:30:00.0000000+00:00", "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "operationId": "0HN7GK9M4T2R5"}