[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fdocuments\u002Fdownload":3,"docs-tabs-entities\u002Fdocuments\u002Fdownload":6},{"content":4,"lastmod":5},"## Download document DOCX\n\n`GET \u002Fv1\u002Fdocuments\u002F:id\u002Fdownload`\n\nDownloads the DOCX file of a generated document through Vibecode: the platform adds Bitrix24 authorization to the request automatically. A CRM record document is downloaded the same way through its own route.\n\n| Document | Route | Scope |\n|----------|---------|-------|\n| App document | `GET \u002Fv1\u002Fdocuments\u002F:id\u002Fdownload` | `documentgenerator` |\n| CRM record document | `GET \u002Fv1\u002Fcrm-documents\u002F:id\u002Fdownload` | `crm` |\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `id` (path) | number | yes | Document ID, a positive integer. App documents: [`GET \u002Fv1\u002Fdocuments`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Flist), CRM record documents: [`GET \u002Fv1\u002Fcrm-documents`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-list) |\n\nNo request body is sent. The examples below are for an app document. For a CRM record document, replace `documents` with `crm-documents` in the URL.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl --fail-with-body \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdocuments\u002F2001\u002Fdownload\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -o document-2001.docx\n```\n\n### curl — OAuth application\n\n```bash\ncurl --fail-with-body \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdocuments\u002F2001\u002Fdownload\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -o document-2001.docx\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdocuments\u002F2001\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('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fdocuments\u002F2001\u002Fdownload', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\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 fields\n\nOn success the HTTP status is `200 OK` and the response body contains the bytes of the DOCX file. File details come in the headers.\n\n| Header | Example value | Description |\n|-----------|-----------------|----------|\n| `Content-Type` | `application\u002Fvnd.openxmlformats-officedocument.wordprocessingml.document` | Content type that Bitrix24 returned for the document file |\n| `Content-Disposition` | `attachment; filename=\"document-2001.docx\"` | File name for saving, in the form `document-\u003Cid>.docx`. The document title is not included |\n\n## Response example\n\n```http\nHTTP\u002F1.1 200 OK\nContent-Type: application\u002Fvnd.openxmlformats-officedocument.wordprocessingml.document\nContent-Disposition: attachment; filename=\"document-2001.docx\"\nContent-Length: 914\n\n\u003Cbinary .docx content, 914 bytes, starts with PK>\n```\n\n## Error response example\n\n404 — document not found:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ENTITY_NOT_FOUND\",\n    \"message\": \"Document 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: `Document ID must be a positive integer.` |\n| 404 | `ENTITY_NOT_FOUND` | No document with this `id`. Message: `Document not found.` |\n| 409 | `DOCUMENT_NOT_READY` | CRM record documents only: the document has no DOCX file yet. Retry the request in a few seconds |\n| 502 | `DOWNLOAD_FAILED` | Bitrix24 did not return the file: it responded with an error code, sent JSON instead of the file, pointed to a URL outside the Bitrix24 account, or the response could not be read in full. For an app document, also when the file is larger than 10 MiB |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request. The reason is in `error.message` |\n| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denied access to the document. For a CRM record document, also when the record it is attached to does not exist |\n| 403 | `SCOPE_DENIED` | The key lacks the route scope: `documentgenerator` for an app document, `crm` for a CRM record document |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |\n| 401 | `TOKEN_MISSING` | No tokens are mapped to the key — an OAuth application key was called without a user session |\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 just like a full-access key.\n\n**DOCX is ready before PDF and image.** In the first seconds after a document is created, the PDF and image routes respond with `409 DOCUMENT_NOT_READY`, while this route already returns the file.\n\n**The `downloadUrlMachine` field points to this route.** In the responses of [`GET \u002Fv1\u002Fdocuments\u002F:id`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fget) and [`GET \u002Fv1\u002Fcrm-documents\u002F:id`](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get), the field contains the route URL for the same document. API responses contain no Bitrix24 access secrets.\n\n## See also\n\n- [Download document PDF](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fpdf)\n- [Download document image](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fimage)\n- [Get document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fget)\n- [Get CRM document](\u002Fdocs\u002Fentities\u002Fdocuments\u002Fcrm-get)\n- [Documents](\u002Fdocs\u002Fentities\u002Fdocuments)\n","2026-10-09",{},1794739374759]