For AI agents: markdown of this page — /docs-content-en/entities/doc-templates/update.md documentation index — /llms.txt
Update template
PATCH /v1/doc-templates/:id
Partially updates a document template, including replacing its .docx file. Pass only the fields you are changing, flat at the root of the JSON — all other values are preserved.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Parameterid (path) |
Typenumber | Requiredyes | DescriptionTemplate identifier |
Request fields (body)
| Field | Type | Description |
|---|---|---|
Fieldname |
Typestring | DescriptionTemplate name |
FieldnumeratorId |
Typenumber | DescriptionID of the numerator that assigns sequential numbers to documents |
Fieldregion |
Typestring | DescriptionTemplate region code, for example uk or de |
Fieldcode |
Typestring | DescriptionSystem code of the template used to reference it from application code |
Fieldactive |
Typestring | DescriptionTemplate availability: Y — enabled, N — disabled |
FieldwithStamps |
Typestring | DescriptionFacsimile and stamp printing: Y — added, N — not added |
Fieldsort |
Typenumber | DescriptionTemplate order in the list: the lower the value, the higher the template appears |
Fieldusers |
Typearray | DescriptionIdentifiers of employees who have access to the template. List: GET /v1/users |
Fieldfile |
Typestring | DescriptionNew .docx file content as a base64 string. Replaces the template file; the template id stays the same |
The file is replaced only through file. The fileId field, which takes a Drive object ID when creating a template, is not applied on update.
Read-only fields (id, moduleId, createdBy, updatedBy, createTime, updateTime, isDeleted, download, downloadMachine, providers, isDefault, productsTableVariant) are not accepted in the request body: a request carrying any of them is refused with 400 READONLY_FIELD. The owner module moduleId is assigned by the platform.
Examples
curl — personal key
curl -X PATCH "https://vibecode.bitrix24.com/v1/doc-templates/209" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Contract template (updated)"
}'
curl — OAuth application
curl -X PATCH "https://vibecode.bitrix24.com/v1/doc-templates/209" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Contract template (updated)"
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/doc-templates/209', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Contract template (updated)',
}),
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/doc-templates/209', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Contract template (updated)',
}),
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata |
Typeobject | DescriptionThe full updated template |
Fielddata.id |
Typenumber | DescriptionTemplate identifier |
Fielddata.name |
Typestring | DescriptionName |
Fielddata.region |
Typestring | DescriptionRegion |
Fielddata.code |
Typestring | null | DescriptionSystem code of the template |
Fielddata.active |
Typestring | DescriptionAvailability: Y / N |
Fielddata.moduleId |
Typestring | DescriptionSource module of the template |
Fielddata.numeratorId |
Typenumber | DescriptionNumerator identifier |
Fielddata.withStamps |
Typestring | DescriptionStamps and signatures: Y / N |
Fielddata.sort |
Typenumber | DescriptionOrder in the list |
Fielddata.users |
Typeobject | DescriptionMap of employee identifiers with access to the template |
Fielddata.providers |
Typeobject | DescriptionTemplate data providers |
Fielddata.isDeleted |
Typeboolean | DescriptionWhether the template is marked as deleted |
Fielddata.createTime |
Typestring | DescriptionCreation date (ISO 8601) |
Fielddata.updateTime |
Typestring | DescriptionLast update date (ISO 8601) |
Fielddata.download |
Typestring | DescriptionDocument download URL |
Fielddata.downloadMachine |
Typestring | DescriptionVibe API URL; requires X-Api-Key with documentgenerator scope |
Full template field schema — Template fields.
Response example
{
"success": true,
"data": {
"id": 209,
"name": "Contract template (updated)",
"region": "uk",
"code": null,
"download": "/bitrix/services/main/ajax.php?action=documentgenerator.api.template.download&SITE_ID=s1&id=209&ts=0",
"active": "Y",
"moduleId": "rest",
"numeratorId": 1,
"withStamps": "N",
"providers": {
"bitrix\\documentgenerator\\dataprovider\\rest": "bitrix\\documentgenerator\\dataprovider\\rest"
},
"users": {
"U1": "U1"
},
"isDeleted": false,
"sort": 500,
"createTime": "2026-05-12T09:03:38.000Z",
"updateTime": "2026-05-25T10:00:11.000Z",
"downloadMachine": "https://vibecode.bitrix24.com/v1/doc-templates/209/download"
}
}
Error response example
404 — template not found:
{
"success": false,
"error": {
"code": "ENTITY_NOT_FOUND",
"message": "Template was not found."
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeREADONLY_FIELD |
DescriptionThe body carried a read-only field — for example the owner module moduleId, which the platform assigns. The check runs before the call to Bitrix24, so this refusal arrives even for a non-existent id |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionNo template with the given id (message "Template was not found.") |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionThe body carried fileId: null (message "The field FILE_ID is required."). Remove fileId from the body |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key lacks the documentgenerator scope |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe key has no configured tokens |
Full list of common API errors — Errors.
Known specifics
A call with fileId succeeds but does not change the file. A call with a numeric fileId and no file returns 200 and success: true, but the template file stays the same. If you pass both fields, file is applied. So success: true does not confirm the replacement: check the file with GET /v1/doc-templates/:id/download.
The file content is not validated. The call returns 200 even when file does not carry a .docx: the template stores the content as sent, and the file downloaded afterwards does not open as a document. Pass only .docx file content in file.