Documents

Template Update

Markdown for LLMs
PUT
/documents/template/{documentTemplateId}/update

Replaces a document template in full. Every writable field is taken from the request: anything omitted is cleared, not left as it was, so send the complete resource rather than only the parts that change.

A template with loadMethod OneDrive, a url and no urn is looked up on OneDrive through the caller's connected Microsoft account, and the stored urn is set to the OneDrive item id found at url. 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. When url differs from the one stored, the update is saved only if that lookup succeeds: 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. URLs are compared after encoding, so a URL with raw spaces and its encoded form count as the same URL. When url is unchanged, the update is saved even if the lookup fails, and the stored urn is then empty, because an update stores the urn the request sent.

To change just the folder a document template sits in, use documents-template-move instead — that operation takes only the folder rather than the whole record.

Identifiers, ownership and timestamps stay server-assigned and cannot be set here; the id travels in the path, not in the body.

Authorization

AuthorizationBearer <token>

JWT token to authenticate the request.

In: header

X-Api-Key<token>

API key, sent as a request header.

In: header

Path Parameters

documentTemplateId*string

Id of the document template to replace, as returned by documents-template-create in result.data.documentTemplate.id.

Formatuuid

Request Body

application/json

The document template as it should be after the call.

TypeScript Definitions

Use the request body type in TypeScript.

Body for replacing 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 PUT "https://example.com/documents/template/2b7c9e14-5a63-4f08-9d21-7c4e0b8a3f52/update" \  -H "Content-Type: application/json" \  -d '{    "documentTemplate": {      "name": "Standard Invoice",      "description": "Company standard invoice layout, updated for the 2027 branding.",      "title": "Invoice",      "urn": "9f86d081-884c-4d30-8934-9c1e6cbcb9f5",      "fileFormat": "docx",      "loadMethod": "Storage",      "documentSolutions": [        {          "id": "6ccb8ca9-2952-4dbf-a4b0-4a48bdeb1922"        }      ]    },    "externalContext": {      "id": "789"    }  }'
{  "result": {    "statusCode": 200,    "message": "OK",    "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, updated for the 2027 branding.",        "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-24T02:05:18.000Z"      }    }  },  "origin": "PUT https://api.doctavian.com/v1/documents/template/{documentTemplateId}/update",  "dateTime": "2026-09-24T02:05:18.000Z",  "externalContext": {    "id": "789"  },  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "9a2c58fe1b7d40c3ae64b05f7213d8ca"}
{  "error": {    "statusCode": 400,    "message": "The request was rejected.",    "innerErrors": [      {        "code": "TEMPLATE_NAME_REQUIRED",        "message": "The request was rejected.",        "userMessage": "Check the highlighted fields and try again."      }    ]  },  "origin": "PUT https://api.doctavian.com/v1/documents/template/{documentTemplateId}/update",  "dateTime": "2026-09-24T02:05:18.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "9a2c58fe1b7d40c3ae64b05f7213d8ca"}
{  "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": "PUT https://api.doctavian.com/v1/documents/template/{documentTemplateId}/update",  "dateTime": "2026-09-24T02:05:18.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "9a2c58fe1b7d40c3ae64b05f7213d8ca"}
{  "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": "PUT https://api.doctavian.com/v1/documents/template/{documentTemplateId}/update",  "dateTime": "2026-09-24T09:41:06.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "9a2c58fe1b7d40c3ae64b05f7213d8ca"}
{  "error": {    "statusCode": 500,    "message": "The document template could not be updated.",    "innerErrors": [      {        "code": "UPDATE_DOCUMENT_TEMPLATE_ERROR",        "message": "The document template could not be updated.",        "userMessage": "Something went wrong. Please try again or contact support."      }    ]  },  "origin": "PUT https://api.doctavian.com/v1/documents/template/{documentTemplateId}/update",  "dateTime": "2026-09-24T02:05:18.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "9a2c58fe1b7d40c3ae64b05f7213d8ca"}