Documents

Document Manage

POST
/documents/document/manage

This endpoint performs external file operations on existing documents, such as copying, moving, deleting (currently only supports OneDrive), or converting documents, without modifying their internal content. It allows you to manage how and where documents are stored across supported platforms like Storage, Salesforce, and OneDrive. Copy: If both source and target are provided in the payload, the document is duplicated from the source location to the target location. Requires the same fileFormat in both source and target document and source.remove must be "none". Move: Transfers the document from the source to the target location with deletion from the source. Requires the same fileFormat in both source and target document and source.remove must be "delete" or "permanentDelete". Delete: Deletes the specified document if only the source document is provided and source.remove is "delete" or "permanentDelete". Target document is not in the payload in this case. Convert: Transforms the document format (e.g., docx → pdf, xlsx → pdf) while transferring it between same or different locations. Requires both source and target document with differing fileFormat values.

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.


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.

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/documents/document/manage" \  -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:Q3 Sales Report - Archived.docx"      }    }  },  "consumption": [    {      "dimension": "pages-managed",      "value": 4    },    {      "dimension": "documents-managed",      "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"}