Documents

Document Template Upload

POST
/documents/template/upload

This endpoint uploads one or more template files to Storage as multipart form-data, for use in Document Generate requests only. Accepted extensions are .docx, .xlsx and .pptx. Maximum file size is enforced at the gateway: 20MB in Production, 10MB in Staging. A file over that limit is rejected by the web server before the operation runs, so it surfaces as a 500 rather than a validation error.

Each uploaded file is assigned a storage id, returned in form-data order when multiple files are sent in one request. An uploaded template is held in Storage for 24 hours, and is removed sooner than that by the next document-generation request that consumes it — consumption removes it whether that request succeeds or fails. Once it is gone by either route its storage id stops resolving, so upload the template again if you need it.

Templates stored in Google Drive or Microsoft OneDrive are referenced directly in the generate request instead of being uploaded here — see Document Generate for those options.

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

multipart/form-data

TypeScript Definitions

Use the request body type in TypeScript.

body?unknown

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/documents/template/upload" \  -F file="[    \"Standard Invoice.docx\",    \"Quarterly Report.xlsx\"  ]"
{  "result": {    "data": {      "files": [        {          "id": "b1e6d2c9-77aa-4f3b-8c21-9d0e4a6f2b58",          "fileName": "offer.docx"        },        {          "id": "e610ac2d-440e-40a1-b61a-315c26f1618f",          "fileName": "contract.docx"        }      ]    },    "statusCode": 201,    "message": "Created"  },  "origin": "POST https://api.doctavian.com/v1/documents/template/upload",  "dateTime": "2026-09-11T10:46:17.000Z",  "operationId": "3a4b5c6d7e8f90112233445566778899",  "userId": "cd5279bf-b0cc-4220-9f6f-7386467317c3"}
{  "error": {    "statusCode": 400,    "message": "The file 'notes.txt' has an unsupported format. Allowed: .docx,.xlsx,.pptx",    "innerErrors": [      {        "code": "INVALID_TEMPLATE_FORMAT",        "message": "The file 'notes.txt' has an unsupported format. Allowed: .docx,.xlsx,.pptx",        "userMessage": "This template format isn't supported. Upload a .docx, .xlsx or .pptx file."      }    ]  },  "origin": "POST https://api.doctavian.com/v1/documents/template/upload",  "dateTime": "2026-09-11T10:46:17.000Z",  "operationId": "3a4b5c6d7e8f90112233445566778899",  "userId": "cd5279bf-b0cc-4220-9f6f-7386467317c3"}
{  "error": {    "statusCode": 401,    "message": "The request could not be authenticated.",    "innerErrors": [      {        "code": "UNAUTHORIZED",        "message": "The request could not be authenticated.",        "userMessage": "Your session has expired or is invalid. Please sign in again."      }    ]  },  "origin": "POST https://api.doctavian.com/v1/documents/template/upload",  "dateTime": "2026-09-11T10:46:17.000Z",  "operationId": "3a4b5c6d7e8f90112233445566778899",  "userId": "cd5279bf-b0cc-4220-9f6f-7386467317c3"}
{  "error": {    "statusCode": 500,    "message": "Failed to persist the uploaded file to storage.",    "innerErrors": [      {        "code": "FILE_UPLOAD_FAILED",        "message": "Failed to persist the uploaded file to storage.",        "userMessage": "Something went wrong while uploading. Please try again or contact support."      }    ]  },  "origin": "POST https://api.doctavian.com/v1/documents/template/upload",  "dateTime": "2026-09-11T10:46:17.000Z",  "operationId": "3a4b5c6d7e8f90112233445566778899",  "userId": "cd5279bf-b0cc-4220-9f6f-7386467317c3"}