[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fcrm-document-templates\u002Fupdate":3,"docs-tabs-entities\u002Fcrm-document-templates\u002Fupdate":6},{"content":4,"lastmod":5},"## Update a CRM document template\n\n`PATCH \u002Fv1\u002Fcrm-document-templates\u002F:id`\n\nPartially updates a CRM document template: pass only the fields you change at the root of the JSON. The template's other values are kept.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `id` (path) | number | yes | Template ID, a positive integer. List: [`GET \u002Fv1\u002Fcrm-document-templates`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist) |\n\n## Request fields (body)\n\nAll fields are optional, but the body must contain at least one of them.\n\n| Field | Type | Description |\n|------|-----|---------|\n| `name` | string | Template name |\n| `file` | string | New `.docx` file as a base64 string, at most 2 MiB after decoding. Replaces the template file |\n| `numeratorId` | number | ID of the numerator that assigns numbers to documents. The list of numerators is not exposed through `\u002Fv1\u002F...` |\n| `region` | string | Template region, for example `uk` |\n| `entityTypeId` | array | Non-empty array of CRM record types, numbers or strings: `2` — deal, `3` — contact, `4` — company. Smart process types — [`GET \u002Fv1\u002Fsmart-processes`](\u002Fdocs\u002Fentities\u002Fsmart-processes). Replaces the bindings entirely: `[3]` on a deal template leaves only the contact. Without the field, the bindings do not change |\n| `users` | array | Non-empty array of access codes as strings: `UA` — all employees, `U\u003Cid>` — the employee with this ID from [`GET \u002Fv1\u002Fusers`](\u002Fdocs\u002Fentities\u002Fusers) |\n| `active` | string | Whether the template is active: `Y` or `N` |\n| `withStamps` | string | Stamps and signatures in documents: `Y` or `N` |\n| `sort` | number | Sort index |\n| `code` | string | Template symbolic code |\n\nThe 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.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PATCH \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"name\": \"Supply agreement, revision 2\",\n    \"sort\": 200\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PATCH \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"name\": \"Supply agreement, revision 2\",\n    \"sort\": 200\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263', {\n  method: 'PATCH',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    name: 'Supply agreement, revision 2',\n    sort: 200,\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263', {\n  method: 'PATCH',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    name: 'Supply agreement, revision 2',\n    sort: 200,\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data` | object | The full template after the change |\n| `data.id` | string | Template ID, as a string |\n| `data.name` | string | Template name |\n| `data.region` | string | Template region |\n| `data.code` | string \\| null | Template symbolic code, `null` — no code set |\n| `data.download` | string | Template file download URL in the Bitrix24 web interface. To download through the API, use `downloadMachine` |\n| `data.active` | string | Whether the template is active: `Y` or `N` |\n| `data.moduleId` | string | Owner module, always `crm` |\n| `data.numeratorId` | string | Numerator ID, as a string |\n| `data.withStamps` | string | Stamps and signatures: `Y` or `N` |\n| `data.users` | object | Access codes as an object, each code is both the key and the value: `{\"UA\": \"UA\"}` |\n| `data.isDeleted` | string | Deletion flag: `N` for an active template |\n| `data.sort` | string | Sort index, as a string |\n| `data.createTime` | string | Creation date in ISO 8601 with a time zone offset |\n| `data.updateTime` | string | Last modification date in ISO 8601 with a time zone offset |\n| `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](\u002Fdocs\u002Fentities\u002Fcrm-document-templates#what-to-know-before-you-start) |\n| `data.downloadMachine` | string | Download URL of the `.docx` through the Vibecode API — [`GET \u002Fv1\u002Fcrm-document-templates\u002F:id\u002Fdownload`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdownload) |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": \"263\",\n    \"name\": \"Supply agreement, revision 2\",\n    \"region\": \"uk\",\n    \"code\": null,\n    \"download\": \"https:\u002F\u002Fexample.bitrix24.com\u002Fbitrix\u002Fservices\u002Fmain\u002Fajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=263\",\n    \"active\": \"Y\",\n    \"moduleId\": \"crm\",\n    \"numeratorId\": \"1\",\n    \"withStamps\": \"N\",\n    \"users\": {\n      \"UA\": \"UA\"\n    },\n    \"isDeleted\": \"N\",\n    \"sort\": \"200\",\n    \"createTime\": \"2026-10-08T13:20:29+00:00\",\n    \"updateTime\": \"2026-10-08T13:20:41+00:00\",\n    \"entityTypeId\": [\n      \"2_category_0\",\n      \"2_category_1\",\n      \"2_category_11\",\n      \"2_category_13\",\n      \"2_category_21\",\n      \"2_category_3\",\n      \"2_category_5\",\n      \"2_category_9\"\n    ],\n    \"downloadMachine\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263\u002Fdownload\"\n  }\n}\n```\n\n## Error response example\n\n404 — template not found:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ENTITY_NOT_FOUND\",\n    \"message\": \"CRM template not found.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 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](\u002Fdocs\u002Fentities\u002Fdoc-templates) section |\n| 400 | `INVALID_PARAMS` | `id` is not a positive integer |\n| 400 | `MISSING_REQUIRED_FIELDS` | Empty body `{}` |\n| 400 | `INVALID_PARAMS` | `users` is an empty array or contains a value that is not a non-empty string |\n| 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 |\n| 400 | `INVALID_PARAMS` | `file` is not a base64 string |\n| 400 | `INVALID_PARAMS` | The request body is not a JSON object |\n| 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` |\n| 413 | `PAYLOAD_TOO_LARGE` | The file is larger than 2 MiB after decoding `file`, or the JSON body is larger than 3 MiB |\n| 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 |\n| 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 \u002Fv1\u002Fcrm-document-templates\u002F:id`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget) before retrying |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the change. The reason text is in `error.message` |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key works in read-only mode |\n| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |\n| 401 | `TOKEN_MISSING` | The key has no configured tokens |\n| 429 | `RATE_LIMITED` | Bitrix24 rate-limited requests to the portal. Retry after the delay in the `Retry-After` header |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## See also\n\n- [Get a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget)\n- [Create a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fcreate)\n- [List CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist)\n- [Delete a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdelete)\n- [Download a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdownload)\n","2026-10-09",{},1795415217160]