Documents

Document Merge Async

POST
/documents/document/merge/async

This endpoint initiates an asynchronous operation to merge multiple source documents into a single PDF, preserving the order specified in the request. Just like synchronous merge endpoint, it supports platforms like Storage, Salesforce, and OneDrive. 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

Encrypted (AES) JWT token to identify and authorize the calling client system responsible for requesting the document generation. This header is required when retrieving the template and/or data used to populate the template from the client’s side, and for delivering the final generated document on the client’s side.

Default"eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJzZXNzaW9uLTQ0NyJ9.QFq6y3f6c2b7d1a9"
X-Service-Authorization?string

Encrypted (AES) JWT token to represent a user that doesn’t have a Microsoft Account and that is allowed to use the subscription.

Default"eyJhbGciOiJSUzI1NiJ9.eyJhbXBfc3Vic2NyaXB0aW9uIjoic3ViLTg4OSJ9.7f4d1a9c2b6e3f0a"
X-Email?string

Email of the user who starts the process, needed for GAS script processing

Default"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.


sourceDocuments Identifies the input documents (e.g., Word, Excel, or PDF files) and their properties, serving as the inputs for the merge and conversion process to create a unified target document.


targetDocument Defines the properties of the output document resulting from merging the source documents. It specifies the document’s metadata, format (typically PDF for merged outputs), delivery method, storage location, and processing options, determining how the merged document is saved and managed.

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.

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/documents/document/merge/async" \  -H "Content-Type: application/json" \  -d '{    "externalContext": {      "id": "req-2026-0007421"    },    "sourceDocuments": [      {        "urn": "e3b0c442-98fc-4e1a-8a3d-2c1b5f6e9a70",        "loadMethod": "Storage",        "order": 1,        "remove": "none"      },      {        "urn": "5d8e9f0a-1b2c-43d4-95e6-7f8a9b0c1d2e",        "loadMethod": "Storage",        "order": 2,        "remove": "none"      }    ],    "targetDocument": {      "name": "Q3 Sales Report - Merged",      "fileFormat": "pdf",      "deliveryMethod": "Storage",      "path": "root",      "options": {        "pdfSaveOptions": "{ \\"ConformanceLevel\\": \\"PdfA3a\\", \\"Version\\": \\"PDF_1_7\\", \\"ImageDpi\\": 750 }",        "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 - Merged",        "fileFormat": "pdf",        "urn": "c72f4a1e-9d3b-4c5f-8a6e-1b2c3d4e5f6a:Q3 Sales Report - Merged.pdf"      }    }  },  "consumption": [    {      "dimension": "pages-merged",      "value": 4    },    {      "dimension": "documents-merged",      "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"}