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 converting, copying and moving a file — for example, turning a Word document into a PDF before you merge it, or archiving a spreadsheet from OneDrive as a PDF.
Make sure you have:
Authorization bearer token and your API key (x-api-key) — see Authentication.docx or .pdf uploaded with POST /documents/document/upload. The upload's storage id is the source urn. Storage keeps an uploaded file for 24 hours, so manage it within that window.gdoc, gsheet, gslide) can only be loaded from Google Drive.Uploading is covered in Merge Documents; accepted extensions and limits are in Supported File Formats.
There is no "action" field. What happens follows from the source you name in sourceDocument, the result you describe in targetDocument, and sourceDocument.remove:
| To… | Do this |
|---|---|
| Convert | Set targetDocument.fileFormat to a different format the source can become |
| Copy | Keep the source's own format and deliver to a new location |
| Move | Copy, and remove the source: remove: "delete" or "permanentDelete" for a drive source. A Storage source is always removed |
Deleting a file without producing a copy is not possible with this operation.
A Word, spreadsheet or presentation source can become its own Office format or PDF, and a spreadsheet can also become CSV; a PDF stays a PDF. Google formats are never produced — a Google source becomes an Office format, PDF or CSV. The full table is in Supported File Formats.
loadMethod | remove | Source after the call |
|---|---|---|
Storage | Any value, or left out | Always deleted once it has been loaded |
OneDrive, GoogleDrive | delete | Removed |
OneDrive, GoogleDrive | permanentDelete | Removed permanently |
OneDrive, GoogleDrive | Any other value, or left out | Kept |
A Storage source is single-use. It is deleted as soon as manage has loaded it, even with
remove: "none", and even if the operation then fails. A second call with the sameurnfails withFILE_MISSING_FROM_STORAGE. Upload the file again for every Storage manage call.
Upload the .docx with POST /documents/document/upload and take its storage id, then convert it:
POST https://api.doctavian.com/v1/documents/document/manage
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"externalContext": { "caseId": "CASE-2026-0815" },
"sourceDocument": {
"urn": "55ecc75e-5e37-45b2-b4df-bf8255aed71c",
"fileFormat": "docx",
"loadMethod": "Storage"
},
"targetDocument": {
"name": "cover-letter",
"fileFormat": "pdf",
"deliveryMethod": "Storage",
"path": "root"
}
}The response gives the new file's id:
{
"result": {
"statusCode": 201,
"data": {
"document": {
"deliveryMethod": "Storage",
"name": "cover-letter",
"fileFormat": "pdf",
"urn": "d54882e3-e5a0-4c2f-a436-0ee5b1e39d5a"
}
}
},
"externalContext": { "caseId": "CASE-2026-0815" },
...
}The new PDF is at result.data.document.urn. Download it within 24 hours with GET /documents/document/{urn}/download, or use it as a Storage source in a merge. The uploaded .docx is gone.
This converts a Word document on OneDrive to PDF in the drive's root, removes the original, gives everyone in the organization a view link, and gives one user a view link of their own:
POST https://api.doctavian.com/v1/documents/document/manage
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"externalContext": { "id": "req-2026-0007421" },
"sourceDocument": {
"urn": "01BYE5RZ5MYLM2SMX75ZBIPQZIHT6OAYPB",
"fileFormat": "docx",
"loadMethod": "OneDrive",
"remove": "delete"
},
"targetDocument": {
"name": "Q3 Sales Report - Archived",
"fileFormat": "pdf",
"deliveryMethod": "OneDrive",
"path": "",
"options": {
"onedrive": {
"viewOrganization": true,
"viewUsers": [ "jane.doe@example.com" ]
}
}
}
}A drive delivery adds uri, the file's URL, and one link per sharing option you set:
{
"result": {
"data": {
"document": {
"deliveryMethod": "OneDrive",
"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"
},
...
}
}
},
...
}For a drive delivery, urn is the drive's own file id. To copy instead of move, leave remove out.
Load and save options and drive sharing go under sourceDocument.options and targetDocument.options. The available options are listed in Option Definitions, and the full request schema is in the API Reference.
Spreadsheet to PDF. The default pdfSaveOptions include "SelectionType": "EntireFile", which is what puts every sheet in the PDF rather than only the active one. If you send your own pdfSaveOptions, include it.
Most invalid input to manage is reported as 500 with MANAGE_FUNCTION_FAILED, preceded by a more specific code when the cause is known. Branch on error.innerErrors[].code and quote operationId to support — see Error Handling.
A failed call has still consumed a Storage source if it got as far as loading it. Before retrying, upload the file again and use the new id.
POST /documents/document/manage/async runs the same operation in the background. The body and every rule are identical; add the X-Client-Authorization header so Doctavian knows where to deliver the result.
POST https://api.doctavian.com/v1/documents/document/manage/async
Authorization: Bearer <token>
x-api-key: <api-key>
X-Client-Authorization: <result.data.clientToken.token>
Content-Type: application/json
{
"externalContext": { "caseId": "CASE-2026-0815" },
"sourceDocument": {
"urn": "55ecc75e-5e37-45b2-b4df-bf8255aed71c",
"fileFormat": "docx",
"loadMethod": "Storage"
},
"targetDocument": {
"name": "cover-letter",
"fileFormat": "pdf",
"deliveryMethod": "Storage",
"path": "root"
}
}200 with an empty body once the request is queued. That only acknowledges receipt.POSTed to your callback URL: on success the same body as the synchronous response, on failure an error envelope.externalContext.See Receive Callbacks for your endpoint and both callback bodies, and Client Header for generating the header.
removeremove