Document Merge
This endpoint allows you to merge multiple PDF documents into a single consolidated PDF file, preserving the order you specify. The sequence of merged files is determined in the payload in each source document, and all source files must be in PDF format. The merged output can be stored in Storage, Salesforce, or OneDrive and source documents can optionally be removed from the source after merging.
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.
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" \ -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"}