Template Create
Markdown for LLMsCreates a document template: the file a document solution generates from, registered with where it lives and what format it is in. The template file itself is not uploaded here — this records a reference to a file that already exists, either in Doctavian Storage via documents-template-upload or on a connected drive.
Point at the file one of two ways, never both: urn together with loadMethod, or url on its own. fileFormat must agree with loadMethod — the Google formats gdoc, gsheet and gslide only work with GoogleDrive, and docx, xlsx, xlsm and pptx only with Storage or OneDrive.
A template with loadMethod OneDrive, a url and no urn is checked before it is saved: the file at url is looked up on OneDrive through the caller's connected Microsoft account, and the created template's urn is set to the OneDrive item id found there. An empty or whitespace-only urn counts as no urn. A template that sends a urn, or uses any other loadMethod, is not looked up. If the lookup fails, nothing is saved: a file that cannot be found, or a url that is not an https URL, returns 404 TEMPLATE_ONEDRIVE_FILE_NOT_FOUND, any other lookup failure returns 400 TEMPLATE_ONEDRIVE_LOOKUP_FAILED, and a caller with no connected Microsoft account, or one that must be reconnected, gets 400 CONNECTOR_REQUIRED or CONNECTOR_RECONNECT_REQUIRED.
A template can be attached to document solutions in the same call by listing their ids in documentSolutions. That linking is best-effort: a solution that cannot be found is skipped rather than failing the request, so compare the returned list with what you sent.
A Storage template is subject to the upload retention window: files uploaded through documents-template-upload are removed once a document-generation request consumes them or after 24 hours, whichever comes first. The template record survives, but its urn stops resolving, so re-upload the file and update the urn before each generation run. Templates held on OneDrive or Google Drive are not affected.
Identifiers, ownership, folder and timestamps are all server-assigned and returned in the response; sending them has no effect, as does sending path, which exists only for display.
JWT token to authenticate the request.
In: header
API key, sent as a request header.
In: header
Request Body
application/json
The document template to create, as a DocumentTemplateCreateInput wrapped in the standard request envelope. Mandatory. Identifiers, ownership and timestamps are server-assigned and ignored if sent.
TypeScript Definitions
Use the request body type in TypeScript.
Body for creating a document template, following the standard request envelope: the resource under its own name alongside an optional externalContext.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/documents/template/create" \ -H "Content-Type: application/json" \ -d '{ "documentTemplate": { "name": "Standard Invoice", "description": "Company standard invoice layout.", "title": "Invoice", "urn": "9f86d081-884c-4d30-8934-9c1e6cbcb9f5", "fileFormat": "docx", "loadMethod": "Storage", "documentSolutions": [ { "id": "6ccb8ca9-2952-4dbf-a4b0-4a48bdeb1922" } ] }, "externalContext": { "id": "789" } }'{ "result": { "statusCode": 201, "message": "Created", "data": { "documentTemplate": { "id": "2b7c9e14-5a63-4f08-9d21-7c4e0b8a3f52", "subscriptionId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", "ownerId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "lastModifiedUserId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "name": "Standard Invoice", "description": "Company standard invoice layout.", "title": "Invoice", "urn": "9f86d081-884c-4d30-8934-9c1e6cbcb9f5", "fileFormat": "docx", "loadMethod": "Storage", "path": "Templates / Standard Invoice.docx", "documentSolutions": [ { "id": "6ccb8ca9-2952-4dbf-a4b0-4a48bdeb1922", "name": "Quarterly Invoicing", "description": "Invoice run for quarterly billing." } ], "ownerName": "Jane Doe", "lastModifiedUserName": "Jane Doe", "createdDate": "2026-09-18T12:15:53.000Z", "lastModifiedDate": "2026-09-18T12:15:53.000Z" } } }, "origin": "POST https://api.doctavian.com/v1/documents/template/create", "dateTime": "2026-09-18T12:15:53.000Z", "externalContext": { "id": "789" }, "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "operationId": "a0f31d9c6b4e4278ad15e9c73f082b64"}{ "error": { "statusCode": 400, "message": "Name is required.", "innerErrors": [ { "code": "TEMPLATE_NAME_REQUIRED", "message": "Name is required.", "userMessage": "Give the template a name before saving it." } ] }, "origin": "POST https://api.doctavian.com/v1/documents/template/create", "dateTime": "2026-09-18T12:15:53.000Z", "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "operationId": "a0f31d9c6b4e4278ad15e9c73f082b64"}{ "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/create", "dateTime": "2026-09-18T12:15:53.000Z", "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "operationId": "a0f31d9c6b4e4278ad15e9c73f082b64"}{ "error": { "statusCode": 404, "message": "The template file was not found on OneDrive.", "innerErrors": [ { "code": "TEMPLATE_ONEDRIVE_FILE_NOT_FOUND", "message": "The template file was not found on OneDrive.", "userMessage": "We couldn't find this file on OneDrive. Check the link and try again." } ] }, "origin": "POST https://api.doctavian.com/v1/documents/template/create", "dateTime": "2026-09-18T12:15:53.000Z", "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "operationId": "a0f31d9c6b4e4278ad15e9c73f082b64"}{ "error": { "statusCode": 500, "message": "The template could not be created.", "innerErrors": [ { "code": "CREATE_DOCUMENT_TEMPLATE_ERROR", "message": "The template could not be created.", "userMessage": "Something went wrong. Please try again or contact support." } ] }, "origin": "POST https://api.doctavian.com/v1/documents/template/create", "dateTime": "2026-09-18T12:15:53.000Z", "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d", "operationId": "a0f31d9c6b4e4278ad15e9c73f082b64"}