[{"data":1,"prerenderedAt":14},["ShallowReactive",2],{"docs-entities\u002Fcrm-document-templates":3,"docs-tabs-entities\u002Fcrm-document-templates":6},{"content":4,"lastmod":5},"# CRM document templates\n\nA CRM document template is a .docx file with placeholder tags that Bitrix24 uses to generate documents for deals, contacts, companies and other CRM records.\n\nBitrix24 API: `crm.documentgenerator.template.*`\nScope: `crm`\n\n## Operations\n\n- [Create a CRM document template](.\u002Fcrm-document-templates\u002Fcreate.md) — `POST \u002Fv1\u002Fcrm-document-templates`\n- [List CRM document templates](.\u002Fcrm-document-templates\u002Flist.md) — `GET \u002Fv1\u002Fcrm-document-templates`\n- [Get a CRM document template](.\u002Fcrm-document-templates\u002Fget.md) — `GET \u002Fv1\u002Fcrm-document-templates\u002F:id`\n- [Update a CRM document template](.\u002Fcrm-document-templates\u002Fupdate.md) — `PATCH \u002Fv1\u002Fcrm-document-templates\u002F:id`\n- [Delete a CRM document template](.\u002Fcrm-document-templates\u002Fdelete.md) — `DELETE \u002Fv1\u002Fcrm-document-templates\u002F:id`\n- [Templates for a CRM record](.\u002Fcrm-document-templates\u002Favailable.md) — `GET \u002Fv1\u002Fcrm-document-templates\u002Favailable`\n- [Download a template](.\u002Fcrm-document-templates\u002Fdownload.md) — `GET \u002Fv1\u002Fcrm-document-templates\u002F:id\u002Fdownload`\n\n## Key fields\n\n| Field | Description |\n|------|---------|\n| `id` | Template ID. List: [`GET \u002Fv1\u002Fcrm-document-templates`](.\u002Fcrm-document-templates\u002Flist.md) |\n| `name` | Template name |\n| `entityTypeId` | CRM record types the template is available for: `2` — deal, `3` — contact, `4` — company. Smart process types: [`GET \u002Fv1\u002Fsmart-processes`](\u002Fdocs\u002Fentities\u002Fsmart-processes) |\n| `numeratorId` | ID of the numerator that assigns numbers to documents. No `\u002Fv1\u002F...` route lists numerators |\n| `region` | Template region, for example `uk` |\n| `users` | Access codes that define which employees see the template, for example `UA` — all employees, `U\u003Cid>` — the employee with this ID from [`GET \u002Fv1\u002Fusers`](\u002Fdocs\u002Fentities\u002Fusers) |\n| `moduleId` | Owner module, always `crm` for templates in this section |\n\n## What to know before you start\n\n1. This section works only with CRM templates, whose `moduleId` is `crm`. Application templates with `moduleId: rest` are in the [Document templates](\u002Fdocs\u002Fentities\u002Fdoc-templates) section and require the `documentgenerator` scope.\n2. When you create or update a template, pass the template file only as a base64 string in the `file` field. Uploading from Drive by `fileId` is not supported.\n3. A template does not generate a document by itself. [Create a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-create) from the selected template, then find it in the [CRM document list](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-list).\n4. [`GET \u002Fv1\u002Fcrm-document-templates\u002Favailable`](.\u002Fcrm-document-templates\u002Favailable.md) shows which templates apply to a specific deal or contact: its response includes only templates bound to the type of that record and, for a deal, to its pipeline.\n5. A deal's `entityTypeId` is stored expanded by pipeline. The create and update responses with `entityTypeId` in the body echo the value you sent, while the get response and an update without this field show the stored value: a template created with `entityTypeId: [2]` reads back as `2_category_0`, `2_category_1` and so on — one value per pipeline of the Bitrix24 account. `2_category_0` is the general pipeline. The other numbers are pipeline IDs from [`GET \u002Fv1\u002Fdeal-categories`](\u002Fdocs\u002Fentities\u002Fdeal-categories). A smart process with pipelines is stored the same way, but in the form `174_3`: the smart process type and the ID of its pipeline from [`GET \u002Fv1\u002Fcategories\u002F:entityTypeId`](\u002Fdocs\u002Fentities\u002Fcategories\u002Flist).\n\n## Typical scenario\n\n1. Create a template from your own `.docx` via [`POST \u002Fv1\u002Fcrm-document-templates`](.\u002Fcrm-document-templates\u002Fcreate.md) or pick an existing one in [`GET \u002Fv1\u002Fcrm-document-templates`](.\u002Fcrm-document-templates\u002Flist.md).\n2. Check that the template is available for the target record: [`GET \u002Fv1\u002Fcrm-document-templates\u002Favailable?entityTypeId=2&entityId=575`](.\u002Fcrm-document-templates\u002Favailable.md).\n3. Generate a document from the template via [`POST \u002Fv1\u002Fcrm-documents`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-create).\n\n## Limits\n\n| Limit | Value |\n|-------|----------|\n| JSON body on create and update | up to 3 MiB |\n| Template file | up to 2 MiB after decoding `file` |\n| Rate limit | shared across the Vibecode API — see [Limits and optimization](\u002Fdocs\u002Foptimization) |\n\n## See also\n\n- [Documents](\u002Fdocs\u002Fentities\u002Fdocuments)\n- [Document templates](\u002Fdocs\u002Fentities\u002Fdoc-templates)\n- [Entity reference](\u002Fdocs\u002Fentity-api)\n","2026-10-09",{"crm-document-templates\u002Fcreate.md":7,"crm-document-templates\u002Flist.md":8,"crm-document-templates\u002Fget.md":9,"crm-document-templates\u002Fupdate.md":10,"crm-document-templates\u002Fdelete.md":11,"crm-document-templates\u002Favailable.md":12,"crm-document-templates\u002Fdownload.md":13},"## Create a CRM document template\n\n`POST \u002Fv1\u002Fcrm-document-templates`\n\nCreates a CRM document template from a .docx file passed as a base64 string and binds it to CRM record types. Fields go in the JSON root without a wrapper.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `name` | string | yes | Template name |\n| `file` | string | yes | Contents of your `.docx` file as a base64 string, no more than 2 MiB after decoding. See \"Known specifics\" for how to get the string |\n| `numeratorId` | number | yes | ID of the numerator that assigns numbers to documents. A positive integer. The list of numerators is not exposed through `\u002Fv1\u002F...` |\n| `region` | string | yes | Template region, for example `uk` |\n| `entityTypeId` | array | yes | 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) |\n| `users` | array | no | Array of access codes as strings: `UA` — all employees, `U\u003Cid>` — the employee with this ID from [`GET \u002Fv1\u002Fusers`](\u002Fdocs\u002Fentities\u002Fusers). When called with a personal key without this field, the template is available only to the key owner: the response returns that employee's `U\u003Cid>` |\n| `active` | string | no | Whether the template is active: `Y` or `N`. Defaults to `Y` |\n| `withStamps` | string | no | Stamps and signatures in documents: `Y` or `N`. Defaults to `N` |\n| `sort` | number | no | Sort index. Defaults to `500` |\n| `code` | string | no | 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`. The name is compared ignoring case and underscores: `module_id` and `ModuleId` are rejected too.\n\n## Examples\n\nIn the examples, `contract.docx` is your template file. The request body is assembled into the `template.json` file and then sent.\n\n### curl — personal key\n\n```bash\nprintf '{\"name\":\"Supply agreement\",\"numeratorId\":1,\"region\":\"uk\",\"entityTypeId\":[2],\"users\":[\"UA\"],\"file\":\"%s\"}' \\\n  \"$(base64 \u003C contract.docx | tr -d '\\n')\" > template.json\n\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  --data-binary @template.json\n```\n\n### curl — OAuth application\n\n```bash\nprintf '{\"name\":\"Supply agreement\",\"numeratorId\":1,\"region\":\"uk\",\"entityTypeId\":[2],\"users\":[\"UA\"],\"file\":\"%s\"}' \\\n  \"$(base64 \u003C contract.docx | tr -d '\\n')\" > template.json\n\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  --data-binary @template.json\n```\n\n### JavaScript — personal key\n\n```javascript\nimport { readFile } from 'node:fs\u002Fpromises'\n\nconst file = (await readFile('contract.docx')).toString('base64')\n\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    name: 'Supply agreement',\n    numeratorId: 1,\n    region: 'uk',\n    entityTypeId: [2],\n    users: ['UA'],\n    file,\n  }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Template ID:', data.id)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nimport { readFile } from 'node:fs\u002Fpromises'\n\nconst file = (await readFile('contract.docx')).toString('base64')\n\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates', {\n  method: 'POST',\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',\n    numeratorId: 1,\n    region: 'uk',\n    entityTypeId: [2],\n    users: ['UA'],\n    file,\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 created template |\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 serves as both key and 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, exactly as passed in the request. When the template is read, the deal type expands by funnel — see [What to know before you start](\u002Fdocs\u002Fentities\u002Fcrm-document-templates#what-to-know-before-you-start) |\n| `data.downloadMachine` | string | `.docx` download URL through the Vibecode API — [`GET \u002Fv1\u002Fcrm-document-templates\u002F:id\u002Fdownload`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdownload) |\n\n## Response example\n\nHTTP `201`:\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": \"263\",\n    \"name\": \"Supply agreement\",\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\": \"500\",\n    \"createTime\": \"2026-10-08T13:20:29+00:00\",\n    \"updateTime\": \"2026-10-08T13:20:29+00:00\",\n    \"entityTypeId\": [\"2\"],\n    \"downloadMachine\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263\u002Fdownload\"\n  }\n}\n```\n\n## Error response example\n\n400 — a required field is missing:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"MISSING_REQUIRED_FIELDS\",\n    \"message\": \"Required field 'numeratorId' is missing.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `MISSING_REQUIRED_FIELDS` | One of the required fields is missing, or its value is `null`, an empty string or an empty array. An empty body `{}` gets the same code |\n| 400 | `INVALID_PARAMS` | `file` is not a base64 string. A placeholder instead of the file contents is rejected with this code before the request reaches Bitrix24 |\n| 400 | `INVALID_PARAMS` | `users` is not an array of non-empty strings, for example, the `{\"UA\": \"UA\"}` object was passed in the shape the response returns |\n| 400 | `INVALID_PARAMS` | `entityTypeId` is not an array, or it contains a value that is neither a positive number nor a non-empty string |\n| 400 | `INVALID_PARAMS` | `name` or `region` is not a string, `numeratorId` is not a positive integer |\n| 400 | `INVALID_PARAMS` | The request body is not a JSON object |\n| 400 | `READONLY_FIELD` | The body contains a read-only field, for example `moduleId` or `fileId` |\n| 413 | `PAYLOAD_TOO_LARGE` | The file exceeds 2 MiB after decoding `file`, or the JSON body exceeds 3 MiB |\n| 429 | `LARGE_BODY_BACKEND_BUSY` | The body exceeds 1 MiB and the platform is already processing the maximum volume of large bodies. Retry after `Retry-After` seconds |\n| 422 | `BITRIX_WRITE_NOT_APPLIED` | The template was created, but Bitrix24 did not save all of the passed `entityTypeId` or `users`. The created template ID is in `error.details.createdTemplateId`. Check the template with [`GET \u002Fv1\u002Fcrm-document-templates\u002F:id`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget) before retrying: a repeated request creates another template |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the creation. 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## Known specifics\n\n**How to get the `file` value.** Build the base64 string from your file with `base64 \u003C contract.docx | tr -d '\\n'`, on macOS — `base64 -i contract.docx | tr -d '\\n'`. Removing line breaks from the output is mandatory: a string with line breaks fails the base64 check.\n\n## See also\n\n- [List CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist)\n- [Get a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget)\n- [Update a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fupdate)\n- [Delete a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdelete)\n- [Download a template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdownload)\n- [Create a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-create)\n- [Document templates](\u002Fdocs\u002Fentities\u002Fdoc-templates)\n","## List CRM document templates\n\n`GET \u002Fv1\u002Fcrm-document-templates`\n\nReturns the CRM document templates of the Bitrix24 account with filtering, field selection and paginated output.\n\n## Parameters\n\n| Parameter | Type | Default | Description |\n|----------|-----|-----------|---------|\n| `filter` (query) | object | — | Filter by template fields, for example `active`, `id`, `entityTypeId`.\u003Cbr>[Filtering syntax](\u002Fdocs\u002Ffiltering). Example: `?filter[entityTypeId]=2_category_1`. Deal templates are matched only by funnel: the value `2` does not return them |\n| `select` (query) | string | all fields | Comma-separated field selection: `?select=id,name`. The `id`, `download` and `downloadMachine` fields are returned with any `select`. An unknown field name does not cause an error: with `select=foo` the items keep only these three fields |\n| `order` (query) | object | — | Accepted, for example `?order[sort]=ASC`, but does not change the output order. Sorting by a field that is not accepted, for example `order[ID]`, returns `422 BITRIX_ERROR` |\n| `start` (query) | number | `0` | Position of the next batch — the `meta.next` value from the previous response |\n\n**Pagination.** Request the next batch with `start` equal to `meta.next` from the previous response. `meta.next: null` means there are no more templates. An arbitrary `start` value does not shift the output: on a Bitrix24 account with 11 templates, `start=2` returned the same 11 templates as `start=0`, and `start=50` returned an empty `data.templates` with `meta.total: 11`.\n\n**Output order.** The keys of `data.templates` always go in ascending `id` order: requests with `order[sort]=ASC` and `order[name]=DESC` returned the templates in the same order. Apply the order you need on your side, for example by sorting `Object.values(data.templates)` by `sort`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\"\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates', {\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nconst { success, data, meta } = await res.json()\nconst templates = Object.values(data.templates)\nconsole.log(`Found ${meta.total} templates`, templates.map(t => t.name))\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nconst { success, data, meta } = await res.json()\nconst templates = Object.values(data.templates)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.templates` | object | Templates. The key is the template ID as a string, and the value is the template record |\n| `data.templates.{id}.id` | string | Template ID |\n| `data.templates.{id}.name` | string | Name |\n| `data.templates.{id}.active` | string | Availability: `Y` \u002F `N` |\n| `data.templates.{id}.code` | string \\| null | Symbolic code of the template, `null` — no code set |\n| `data.templates.{id}.region` | string | Template region, for example `uk` |\n| `data.templates.{id}.sort` | string | Position in the list |\n| `data.templates.{id}.createTime` | string | Creation date in ISO 8601 |\n| `data.templates.{id}.updateTime` | string | Modification date in ISO 8601 |\n| `data.templates.{id}.createdBy` | string | ID of the employee who created the template. List: [`GET \u002Fv1\u002Fusers`](\u002Fdocs\u002Fentities\u002Fusers) |\n| `data.templates.{id}.updatedBy` | string | ID of the employee who modified the template. List: [`GET \u002Fv1\u002Fusers`](\u002Fdocs\u002Fentities\u002Fusers) |\n| `data.templates.{id}.moduleId` | string | Owner module, always `crm` in this section |\n| `data.templates.{id}.numeratorId` | string | ID of the numerator that assigns numbers to documents |\n| `data.templates.{id}.withStamps` | string | Stamps and signatures: `Y` \u002F `N` |\n| `data.templates.{id}.productsTableVariant` | string | Variant of the product table in the document |\n| `data.templates.{id}.isDeleted` | string | Whether the template is marked as deleted: `Y` \u002F `N` |\n| `data.templates.{id}.isDefault` | string | Default template: `Y` \u002F `N` |\n| `data.templates.{id}.download` | string | URL for downloading the template file in the Bitrix24 web interface. To download through the API, use `downloadMachine` |\n| `data.templates.{id}.downloadMachine` | string | Link for downloading the template file through the Vibecode API — [`GET \u002Fv1\u002Fcrm-document-templates\u002F:id\u002Fdownload`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdownload) |\n| `meta.total` | number | Number of templates matching the filter |\n| `meta.start` | number | The `start` value from the request |\n| `meta.next` | number \\| null | The `start` value for the next batch. `null` — there are no more templates |\n\n## Response example\n\nShowing 3 of 11 templates.\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"templates\": {\n      \"87\": {\n        \"id\": \"87\",\n        \"active\": \"Y\",\n        \"name\": \"Addresses\",\n        \"code\": null,\n        \"region\": \"uk\",\n        \"sort\": \"366\",\n        \"createTime\": \"2022-11-23T14:42:12+00:00\",\n        \"updateTime\": \"2023-01-17T11:36:04+00:00\",\n        \"createdBy\": \"1\",\n        \"updatedBy\": \"1\",\n        \"moduleId\": \"crm\",\n        \"numeratorId\": \"1\",\n        \"withStamps\": \"Y\",\n        \"productsTableVariant\": \"\",\n        \"isDeleted\": \"N\",\n        \"isDefault\": \"N\",\n        \"download\": \"https:\u002F\u002Fexample.bitrix24.com\u002Fbitrix\u002Fservices\u002Fmain\u002Fajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=87\",\n        \"downloadMachine\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\u002Fdownload\"\n      },\n      \"129\": {\n        \"id\": \"129\",\n        \"active\": \"Y\",\n        \"name\": \"Product link\",\n        \"code\": null,\n        \"region\": \"uk\",\n        \"sort\": \"900\",\n        \"createTime\": \"2023-05-16T18:43:02+00:00\",\n        \"updateTime\": \"2023-05-16T18:49:36+00:00\",\n        \"createdBy\": \"1\",\n        \"updatedBy\": \"1\",\n        \"moduleId\": \"crm\",\n        \"numeratorId\": \"1\",\n        \"withStamps\": \"Y\",\n        \"productsTableVariant\": \"\",\n        \"isDeleted\": \"N\",\n        \"isDefault\": \"N\",\n        \"download\": \"https:\u002F\u002Fexample.bitrix24.com\u002Fbitrix\u002Fservices\u002Fmain\u002Fajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=129\",\n        \"downloadMachine\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F129\u002Fdownload\"\n      },\n      \"249\": {\n        \"id\": \"249\",\n        \"active\": \"Y\",\n        \"name\": \"Demo product sale\",\n        \"code\": null,\n        \"region\": \"uk\",\n        \"sort\": \"500\",\n        \"createTime\": \"2026-08-19T14:55:23+00:00\",\n        \"updateTime\": \"2026-08-19T14:55:23+00:00\",\n        \"createdBy\": \"1\",\n        \"updatedBy\": null,\n        \"moduleId\": \"crm\",\n        \"numeratorId\": \"1095\",\n        \"withStamps\": \"N\",\n        \"productsTableVariant\": \"\",\n        \"isDeleted\": \"N\",\n        \"isDefault\": \"N\",\n        \"download\": \"https:\u002F\u002Fexample.bitrix24.com\u002Fbitrix\u002Fservices\u002Fmain\u002Fajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=249\",\n        \"downloadMachine\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F249\u002Fdownload\"\n      }\n    }\n  },\n  \"meta\": {\n    \"total\": 11,\n    \"start\": 0,\n    \"next\": null\n  }\n}\n```\n\n## Error response example\n\n400 — `start` is not a non-negative integer:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_START\",\n    \"message\": \"start must be one non-negative safe integer.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_START` | `start` is not a non-negative integer or is passed in the request more than once |\n| 400 | `INVALID_PARAMS` | `select` is empty, or `filter` or `order` is not passed as an object |\n| 400 | `UNKNOWN_FILTER_FIELD` | Filter by a field that is not accepted, for example `filter[foo]` |\n| 422 | `BITRIX_ERROR` | Sorting by a field that is not accepted, for example `order[ID]`. `error.b24Code` contains `INVALID_ARG_VALUE` |\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## Known specifics\n\n**Bindings and access permissions are returned only in the single-template response.** List items have no `entityTypeId` and `users` fields. The record types the template is bound to and the access codes are returned by [Get a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget).\n\n## See also\n\n- [Get a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget)\n- [Get templates for a CRM record](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Favailable)\n- [Create a template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fcreate)\n- [Download a template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdownload)\n- [CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates)\n- [Filtering syntax](\u002Fdocs\u002Ffiltering)\n","## Get a CRM document template\n\n`GET \u002Fv1\u002Fcrm-document-templates\u002F:id`\n\nReturns a single CRM document template by ID, together with the record types it is linked to and the employee access codes.\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## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\"\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87', {\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nconst { success, data } = await res.json()\nconsole.log('Template:', data.name, 'linked to:', data.entityTypeId)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\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 template |\n| `data.id` | string | Template ID |\n| `data.name` | string | Name |\n| `data.region` | string | Template region, for example `uk` |\n| `data.code` | string \\| null | Symbolic code of the template |\n| `data.active` | string | Availability: `Y` \u002F `N` |\n| `data.moduleId` | string | Owner module, always `crm` in this section |\n| `data.numeratorId` | string | ID of the numerator that assigns numbers to documents |\n| `data.withStamps` | string | Stamps and signatures: `Y` \u002F `N` |\n| `data.users` | object | Access codes of the employees who can see the template. The key and the value are identical and equal to the access code, for example `{\"UA\": \"UA\"}` means all employees |\n| `data.isDeleted` | string | Whether the template is marked as deleted: `Y` \u002F `N` |\n| `data.sort` | string | Sort order in the list |\n| `data.createTime` | string | Creation date in ISO 8601 |\n| `data.updateTime` | string | Modification date in ISO 8601 |\n| `data.entityTypeId` | array | CRM record types the template is linked to, as strings: `1` — lead, `3` — contact, `4` — company. Deals are broken down by funnel — `2_category_0`, `2_category_1` and so on, see [CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates) for details. A smart process with funnels is returned as `174_3`: the smart process type and the ID of its funnel. Smart process types: [`GET \u002Fv1\u002Fsmart-processes`](\u002Fdocs\u002Fentities\u002Fsmart-processes) |\n| `data.download` | string | Download URL of the template file in the Bitrix24 web interface. To download through the API, use `downloadMachine` |\n| `data.downloadMachine` | string | Link for downloading the template file 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\": \"87\",\n    \"name\": \"Addresses\",\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=87\",\n    \"active\": \"Y\",\n    \"moduleId\": \"crm\",\n    \"numeratorId\": \"1\",\n    \"withStamps\": \"Y\",\n    \"users\": {\n      \"UA\": \"UA\"\n    },\n    \"isDeleted\": \"N\",\n    \"sort\": \"366\",\n    \"createTime\": \"2022-11-23T14:42:12+00:00\",\n    \"updateTime\": \"2023-01-17T11:36:04+00:00\",\n    \"entityTypeId\": [\n      \"4\",\n      \"3\",\n      \"2_category_0\",\n      \"2_category_1\",\n      \"2_category_3\",\n      \"174_3\",\n      \"177_7\",\n      \"177_9\",\n      \"185_11\",\n      \"1\",\n      \"31_5\"\n    ],\n    \"downloadMachine\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\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` | There is no template with this `id` on the portal |\n| 404 | `ENTITY_NOT_FOUND` | A template with this `id` exists, but its `moduleId` is not `crm`, for example an application template. To read application templates, use [`GET \u002Fv1\u002Fdoc-templates\u002F:id`](\u002Fdocs\u002Fentities\u002Fdoc-templates\u002Fget) |\n| 400 | `INVALID_PARAMS` | `id` is not a positive integer |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request to read the template. The reason is in `error.message` |\n| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |\n| 401 | `TOKEN_MISSING` | The key has no tokens configured |\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- [List CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist)\n- [Get templates for a CRM record](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Favailable)\n- [Update a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fupdate)\n- [Download a template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fdownload)\n- [CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates)\n","## 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","## Delete a CRM document template\n\n`DELETE \u002Fv1\u002Fcrm-document-templates\u002F:id`\n\nDeletes a CRM document template by its ID. A deleted template cannot be restored via the API — create a new one if needed.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `id` (path) | number | yes | Template identifier. List: [`GET \u002Fv1\u002Fcrm-document-templates`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist) |\n\nNo request body is sent.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X DELETE \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X DELETE \"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```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F263', {\n  method: 'DELETE',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nconst body = await res.json()\nif (body.success) {\n  console.log('Template deleted')\n}\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: 'DELETE',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nconst body = await res.json()\nif (body.success) {\n  console.log('Template deleted')\n}\n```\n\n## Response fields\n\nOn successful deletion, HTTP status `200 OK` is returned.\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | `true` — the template is deleted |\n| `data` | null | Deletion result, always `null` |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": null\n}\n```\n\n## Error response example\n\n404 — template not found, including when the same `id` is deleted again:\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| 400 | `INVALID_PARAMS` | `id` is not a positive integer, for example `abc`. Message: `Template ID must be a positive integer.` |\n| 404 | `ENTITY_NOT_FOUND` | No template with this `id` exists, it has already been deleted, or it does not belong to the CRM module. The template is not deleted. Templates with `moduleId: rest` are deleted by [`DELETE \u002Fv1\u002Fdoc-templates\u002F:id`](\u002Fdocs\u002Fentities\u002Fdoc-templates\u002Fdelete) |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the deletion. The reason is in `error.message` |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. Deletion requires a key with write access |\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- [List CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist)\n- [Create a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fcreate)\n- [CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates)\n","## Get templates for a CRM record\n\n`GET \u002Fv1\u002Fcrm-document-templates\u002Favailable`\n\nReturns the CRM document templates that can be applied to a specific deal, contact, company or smart process item. The response includes templates bound to the record type and, for a deal, to its funnel.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `entityTypeId` (query) | number | yes | CRM record type: `2` — deal, `3` — contact, `4` — company. Smart process types: [`GET \u002Fv1\u002Fsmart-processes`](\u002Fdocs\u002Fentities\u002Fsmart-processes). A positive integer, passed once |\n| `entityId` (query) | number | yes | ID of a record of the given type, for example a deal from [`GET \u002Fv1\u002Fdeals`](\u002Fdocs\u002Fentities\u002Fdeals\u002Flist), a contact from [`GET \u002Fv1\u002Fcontacts`](\u002Fdocs\u002Fentities\u002Fcontacts\u002Flist), a company from [`GET \u002Fv1\u002Fcompanies`](\u002Fdocs\u002Fentities\u002Fcompanies\u002Flist) or a smart process item from [`GET \u002Fv1\u002Fitems\u002F:entityTypeId`](\u002Fdocs\u002Fentities\u002Fitems\u002Flist). A positive integer, passed once |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002Favailable?entityTypeId=2&entityId=575\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002Favailable?entityTypeId=2&entityId=575\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\"\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002Favailable?entityTypeId=2&entityId=575', {\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nconst { success, data } = await res.json()\nconsole.log('Templates for the deal:', data.templates.map(t => t.title))\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002Favailable?entityTypeId=2&entityId=575', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\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.templates` | array | Templates available for the record. An empty array means no matching templates |\n| `data.templates[].id` | number | Template ID. Full template record: [`GET \u002Fv1\u002Fcrm-document-templates\u002F:id`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget) |\n| `data.templates[].title` | string | Template name |\n| `data.templates[].documentCreationUrl` | string | Relative path to the page that creates a document from this template for this record in the Bitrix24 web interface, without the Bitrix24 account domain |\n| `data.templates[].isWithStamps` | boolean | Whether the document includes stamps and signatures |\n\n## Response example\n\nDeal 575 is in the funnel with ID 1. Three of the four templates are shown.\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"templates\": [\n      {\n        \"id\": 87,\n        \"title\": \"Addresses\",\n        \"documentCreationUrl\": \"\u002Fbitrix\u002Fcomponents\u002Fbitrix\u002Fcrm.document.view\u002Fslider.php?providerClassName=Bitrix%5CCrm%5CIntegration%5CDocumentGenerator%5CDataProvider%5CDeal&value=575&templateId=87\",\n        \"isWithStamps\": true\n      },\n      {\n        \"id\": 249,\n        \"title\": \"Demo product sale\",\n        \"documentCreationUrl\": \"\u002Fbitrix\u002Fcomponents\u002Fbitrix\u002Fcrm.document.view\u002Fslider.php?providerClassName=Bitrix%5CCrm%5CIntegration%5CDocumentGenerator%5CDataProvider%5CDeal&value=575&templateId=249\",\n        \"isWithStamps\": false\n      },\n      {\n        \"id\": 251,\n        \"title\": \"Array format check\",\n        \"documentCreationUrl\": \"\u002Fbitrix\u002Fcomponents\u002Fbitrix\u002Fcrm.document.view\u002Fslider.php?providerClassName=Bitrix%5CCrm%5CIntegration%5CDocumentGenerator%5CDataProvider%5CDeal&value=575&templateId=251\",\n        \"isWithStamps\": false\n      }\n    ]\n  }\n}\n```\n\n## Error response example\n\n404 — no CRM record with this `entityId`:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ENTITY_NOT_FOUND\",\n    \"message\": \"CRM record not found.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 404 | `ENTITY_NOT_FOUND` | No record with this `entityId` exists for this `entityTypeId`. The record's existence is checked before templates are requested |\n| 400 | `INVALID_PARAMS` | `entityTypeId` or `entityId` is missing, is not a positive integer or is passed more than once |\n| 422 | `BITRIX_ERROR` | Bitrix24 does not support this `entityTypeId`, for example `999`: `error.b24Code` equals `ENTITY_TYPE_NOT_SUPPORTED` |\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## Known specifics\n\n**Items in this response differ from the template record.** Here `id` is a number and the name is in the `title` field. In the [template list](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist) and when [getting a template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget), `id` is a string and the name is in the `name` field. When matching templates from the two responses, cast `id` to the same type.\n\n## See also\n\n- [List CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist)\n- [Get a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget)\n- [Create a CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-create)\n- [CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates)\n- [Deals](\u002Fdocs\u002Fentities\u002Fdeals)\n- [Smart processes](\u002Fdocs\u002Fentities\u002Fsmart-processes)\n","## Download a CRM document template\n\n`GET \u002Fv1\u002Fcrm-document-templates\u002F:id\u002Fdownload`\n\nDownloads the source .docx file of a CRM document template through Vibecode: the platform adds Bitrix24 authorization to the request for you.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `id` (path) | number | yes | Template ID. List: [`GET \u002Fv1\u002Fcrm-document-templates`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist) |\n\nThe request has no body.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -H \"X-Api-Key: YOUR_API_KEY\" \\\n  \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\u002Fdownload\" \\\n  -o template-87.docx\n```\n\n### curl — OAuth application\n\n```bash\ncurl -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\u002Fdownload\" \\\n  -o template-87.docx\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch(\n  'https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\u002Fdownload',\n  { headers: { 'X-Api-Key': 'YOUR_API_KEY' } }\n)\n\nif (!res.ok) {\n  const body = await res.json()\n  throw new Error(body.error?.code ?? String(res.status))\n}\n\nconst blob = await res.blob()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch(\n  'https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-document-templates\u002F87\u002Fdownload',\n  {\n    headers: {\n      'X-Api-Key': 'YOUR_APP_KEY',\n      'Authorization': 'Bearer USER_SESSION_TOKEN',\n    },\n  }\n)\n\nif (!res.ok) {\n  const body = await res.json()\n  throw new Error(body.error?.code ?? String(res.status))\n}\n\nconst blob = await res.blob()\n```\n\n## Response headers\n\nOn success, the response has HTTP status `200 OK`, and the body contains the bytes of the .docx file.\n\n| Header | Example value | Description |\n|-----------|-----------------|----------|\n| `Content-Type` | `application\u002Fvnd.openxmlformats-officedocument.wordprocessingml.document` | Content type that Bitrix24 returned for the template file |\n| `Content-Disposition` | `attachment; filename=\"template-87.docx\"` | File name for saving. Built from the template `id` as `template-\u003Cid>.docx`; the template name is not part of it |\n\n## Response example\n\n```http\nHTTP\u002F1.1 200 OK\nContent-Type: application\u002Fvnd.openxmlformats-officedocument.wordprocessingml.document\nContent-Disposition: attachment; filename=\"template-87.docx\"\nTransfer-Encoding: chunked\n\n\u003Cbinary .docx content, 10872 bytes, starts with PK>\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| 400 | `INVALID_PARAMS` | `id` is not a positive integer. Message: `Template ID must be a positive integer.` |\n| 404 | `ENTITY_NOT_FOUND` | No template with this `id` exists, or it does not belong to the CRM module. Message: `CRM template not found.` |\n| 404 | `ENTITY_NOT_FOUND` | The template exists but has no download URL. Message: `CRM template download not found.` |\n| 502 | `DOWNLOAD_FAILED` | Bitrix24 did not return the file: it responded with an error code, for example `Bitrix24 returned 403`, or returned a URL outside the portal or without HTTPS |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request to read the template. The reason is in `error.message` |\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## Known specifics\n\n**A read-only key works.** Downloading does not count as a write, so a key without write permission gets the file the same way as a full-access key.\n\n**The `downloadMachine` field points here.** In the responses of [`GET \u002Fv1\u002Fcrm-document-templates\u002F:id`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget) and [`GET \u002Fv1\u002Fcrm-document-templates`](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist), this field contains the URL of this endpoint.\n\n## See also\n\n- [Get a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fget)\n- [List CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Flist)\n- [Update a CRM document template](\u002Fdocs\u002Fentities\u002Fcrm-document-templates\u002Fupdate)\n- [CRM document templates](\u002Fdocs\u002Fentities\u002Fcrm-document-templates)\n",1794739349616]