For AI agents: markdown of this page — /docs-content-en/entities/crm-document-templates/update.md documentation index — /llms.txt

Update a CRM document template

PATCH /v1/crm-document-templates/:id

Partially updates a CRM document template: pass only the fields you change at the root of the JSON. The template's other values are kept.

Parameters

Parameter Type Required Description
id (path) number yes Template ID, a positive integer. List: GET /v1/crm-document-templates

Request fields (body)

All fields are optional, but the body must contain at least one of them.

Field Type Description
name string Template name
file string New .docx file as a base64 string, at most 2 MiB after decoding. Replaces the template file
numeratorId number ID of the numerator that assigns numbers to documents. The list of numerators is not exposed through /v1/...
region string Template region, for example uk
entityTypeId array Non-empty array of CRM record types, numbers or strings: 2 — deal, 3 — contact, 4 — company. Smart process types — GET /v1/smart-processes. Replaces the bindings entirely: [3] on a deal template leaves only the contact. Without the field, the bindings do not change
users array Non-empty array of access codes as strings: UA — all employees, U<id> — the employee with this ID from GET /v1/users
active string Whether the template is active: Y or N
withStamps string Stamps and signatures in documents: Y or N
sort number Sort index
code string Template symbolic code

The fields id, fileId, moduleId, download, downloadMachine, isDeleted, isDefault, createTime, updateTime, createdBy, updatedBy, providers are read-only. A request with any of them is rejected with 400 READONLY_FIELD. Field names are matched case-insensitively and ignoring underscores: module_id and ModuleId are rejected too.

Examples

curl — personal key

Terminal
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-document-templates/263" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Supply agreement, revision 2",
    "sort": 200
  }'

curl — OAuth application

Terminal
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-document-templates/263" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Supply agreement, revision 2",
    "sort": 200
  }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-document-templates/263', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Supply agreement, revision 2',
    sort: 200,
  }),
})

const { success, data } = await res.json()

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-document-templates/263', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Supply agreement, revision 2',
    sort: 200,
  }),
})

const { success, data } = await res.json()

Response fields

Field Type Description
success boolean Always true on success
data object The full template after the change
data.id string Template ID, as a string
data.name string Template name
data.region string Template region
data.code string | null Template symbolic code, null — no code set
data.download string Template file download URL in the Bitrix24 web interface. To download through the API, use downloadMachine
data.active string Whether the template is active: Y or N
data.moduleId string Owner module, always crm
data.numeratorId string Numerator ID, as a string
data.withStamps string Stamps and signatures: Y or N
data.users object Access codes as an object, each code is both the key and the value: {"UA": "UA"}
data.isDeleted string Deletion flag: N for an active template
data.sort string Sort index, as a string
data.createTime string Creation date in ISO 8601 with a time zone offset
data.updateTime string Last modification date in ISO 8601 with a time zone offset
data.entityTypeId array CRM record types as strings. If entityTypeId was in the request body, the values match those sent. Without it, the deal type comes back expanded by funnel — see What to know before you start
data.downloadMachine string Download URL of the .docx through the Vibecode API — GET /v1/crm-document-templates/:id/download

Response example

JSON
{
  "success": true,
  "data": {
    "id": "263",
    "name": "Supply agreement, revision 2",
    "region": "uk",
    "code": null,
    "download": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=263",
    "active": "Y",
    "moduleId": "crm",
    "numeratorId": "1",
    "withStamps": "N",
    "users": {
      "UA": "UA"
    },
    "isDeleted": "N",
    "sort": "200",
    "createTime": "2026-10-08T13:20:29+00:00",
    "updateTime": "2026-10-08T13:20:41+00:00",
    "entityTypeId": [
      "2_category_0",
      "2_category_1",
      "2_category_11",
      "2_category_13",
      "2_category_21",
      "2_category_3",
      "2_category_5",
      "2_category_9"
    ],
    "downloadMachine": "https://vibecode.bitrix24.com/v1/crm-document-templates/263/download"
  }
}

Error response example

404 — template not found:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "CRM template not found."
  }
}

Errors

HTTP Code Description
404 ENTITY_NOT_FOUND No template with this id, or it is not a CRM template, for example an application template from the Document templates section
400 INVALID_PARAMS id is not a positive integer
400 MISSING_REQUIRED_FIELDS Empty body {}
400 INVALID_PARAMS users is an empty array or contains a value that is not a non-empty string
400 INVALID_PARAMS entityTypeId is an empty array, not an array, or contains a value that is neither a positive number nor a non-empty string
400 INVALID_PARAMS file is not a base64 string
400 INVALID_PARAMS The request body is not a JSON object
400 READONLY_FIELD The body contains a read-only field. The check runs before the template lookup, so this error is also returned for a nonexistent id
413 PAYLOAD_TOO_LARGE The file is larger than 2 MiB after decoding file, or the JSON body is larger than 3 MiB
429 LARGE_BODY_BACKEND_BUSY The body is larger than 1 MiB and the platform is already processing the maximum volume of large bodies. Retry the request after Retry-After seconds
422 BITRIX_WRITE_NOT_APPLIED Bitrix24 did not save the passed entityTypeId or users. The other fields from the body are already written — read the template through GET /v1/crm-document-templates/:id before retrying
422 BITRIX_ERROR Bitrix24 rejected the change. The reason text is in error.message
403 WRITE_BLOCKED_READONLY_KEY The key works in read-only mode
403 SCOPE_DENIED The key lacks the crm scope
401 TOKEN_MISSING The key has no configured tokens
429 RATE_LIMITED Bitrix24 rate-limited requests to the portal. Retry after the delay in the Retry-After header

Full list of common API errors — Errors.

See also