[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fcrm-document-templates\u002Fdownload":3,"docs-tabs-entities\u002Fcrm-document-templates\u002Fdownload":6},{"content":4,"lastmod":5},"## 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","2026-10-09",{},1794739350187]