Documents

Document Manage

Markdown for LLMs
POST
/documents/document/manage

Loads one existing file, optionally converts it to another format, and delivers the result to a new location. It is the operation behind copying, moving and converting a file. The request does not name the action: what happens follows from sourceDocument, targetDocument and sourceDocument.remove. Both sourceDocument and targetDocument are required.

Name the file to load in sourceDocument: its urn in the location given by loadMethod (Storage, OneDrive or GoogleDrive) and its fileFormat. Describe the result in targetDocument: its name, fileFormat, deliveryMethod and path. The target fileFormat must be one the source can become — a docx or gdoc becomes docx or pdf; an xlsx or gsheet becomes xlsx, pdf or csv; a pptx or gslide becomes pptx or pdf; a pdf stays pdf. Keeping the source's own format copies the file.

A Storage source is always deleted once it has been loaded, whatever remove says. For a OneDrive or GoogleDrive source, remove decides: delete or permanentDelete removes it, and any other value keeps it. Moving a file is therefore a copy to the new location with the source removed.

A request without targetDocument fails with 500 MANAGE_FUNCTION_FAILED, whatever the source, and the source file is not deleted. Deleting a file without producing a copy is not possible through this operation.

The response is sent with HTTP 200. The body reports the operation's own status in result.statusCode: 201. To run the same operation without holding the connection open, use documents-document-manage-async.

Authorization

AuthorizationBearer <token>

JWT token to authenticate the request.

In: header

X-Api-Key<token>

API key, sent as a request header.

In: header

Request Body

application/json

Mandatory. The file to load under sourceDocument, and optionally the file to produce under targetDocument, plus an optional externalContext.

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

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": "OneDrive",      "remove": "delete",      "options": {}    },    "targetDocument": {      "name": "Q3 Sales Report - Archived",      "fileFormat": "pdf",      "deliveryMethod": "OneDrive",      "path": "",      "options": {        "onedrive": {          "viewAnonymous": false,          "editAnonymous": false,          "viewOrganization": true,          "editOrganization": false,          "viewUsers": [            "jane.doe@example.com"          ],          "editUsers": []        }      }    },    "data": {}  }'
{  "result": {    "statusCode": 201,    "message": "Created",    "data": {      "document": {        "deliveryMethod": "OneDrive",        "name": "Q3 Sales Report - Archived",        "fileFormat": "pdf",        "urn": "01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36K",        "uri": "https://contoso-my.sharepoint.com/personal/jane_doe_contoso_com/Documents/Q3%20Sales%20Report%20-%20Archived.pdf",        "oneDriveProperties": {          "viewOrganizationUrl": "https://contoso-my.sharepoint.com/:b:/g/personal/jane_doe_contoso_com/EaBcDeFgHiJkLmNoPqRsTuV",          "viewUsersUrl": "https://contoso-my.sharepoint.com/:b:/g/personal/jane_doe_contoso_com/EwXyZaBcDeFgHiJkLmNoPq"        }      }    }  },  "consumption": [    {      "dimension": "documents-managed",      "value": 1    }  ],  "externalContext": {    "id": "req-2026-0007421"  },  "origin": "POST https://api.doctavian.com/v1/documents/document/manage",  "dateTime": "2026-10-09T09:12:44.000Z",  "userId": "1fa93f1d-07e8-4e08-84e6-c0098f3b6ed5",  "operationId": "3f8d1a6b2c9e4f7085b1d4e7a2c6f903"}
Empty
{  "error": {    "statusCode": 403,    "message": "Forbidden",    "innerErrors": [      {        "code": "LIMIT_BREACH",        "message": "Limit has been breached for DOCUMENTS. Current usage is 1000, limit is 1000 for period month.",        "userMessage": "Limit has been breached for DOCUMENTS. Current usage is 1000, limit is 1000 for period month."      }    ],    "externalErrors": []  },  "externalContext": {    "id": "req-2026-0007421"  },  "origin": "POST https://api.doctavian.com/v1/documents/document/manage",  "dateTime": "2026-10-09T09:12:44.000Z",  "userId": "1fa93f1d-07e8-4e08-84e6-c0098f3b6ed5",  "operationId": "b9d2e6a41f7c48035e9a1c3d8b6f2e70"}
{  "error": {    "statusCode": 500,    "message": "Internal Server Error",    "innerErrors": [      {        "code": "MANAGE_FUNCTION_FAILED",        "message": "Failed to manage the document.",        "userMessage": "There was an issue managing the document. Please check the input data and try again.",        "eventId": "a83f1c06-4e9d-47b2-8c5a-1f7e3d9b6c24"      }    ],    "externalErrors": []  },  "externalContext": {    "id": "req-2026-0007421"  },  "origin": "POST https://api.doctavian.com/v1/documents/document/manage",  "dateTime": "2026-10-09T09:12:44.000Z",  "userId": "1fa93f1d-07e8-4e08-84e6-c0098f3b6ed5",  "operationId": "e2b47f90c8a1436db95e0c7a1f3d8b62"}