For AI agents: markdown of this page — /docs-content-en/entities/documents/download.md documentation index — /llms.txt
Download document DOCX
Download the generated DOCX file. Both app and CRM documents use the same download behavior, with different routes and scopes. A READONLY key is accepted.
| Document | HTTP | Scope | Bitrix24 API |
|---|---|---|---|
| App | GET /v1/documents/:id/download |
documentgenerator |
documentgenerator.document.getFile |
| CRM | GET /v1/crm-documents/:id/download |
crm |
crm.documentgenerator.document.download |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
integer | Yes | Positive document ID from GET /v1/documents or GET /v1/crm-documents |
Examples
For CRM documents, replace documents with crm-documents and use crm scope.
cURL: personal key
curl --fail-with-body "https://vibecode.bitrix24.com/v1/documents/73/download" \
-H "X-Api-Key: $VIBE_API_KEY" -o document.docx
cURL: OAuth app
curl --fail-with-body "https://vibecode.bitrix24.com/v1/documents/73/download" \
-H "X-Api-Key: $VIBE_APP_KEY" -H "Authorization: Bearer $B24_ACCESS_TOKEN" -o document.docx
JavaScript: personal key
const response = await fetch('https://vibecode.bitrix24.com/v1/documents/73/download', {
headers: { 'X-Api-Key': vibeApiKey },
});
if (!response.ok) throw new Error(await response.text());
const bytes = await response.arrayBuffer();
JavaScript: OAuth app
const response = await fetch('https://vibecode.bitrix24.com/v1/documents/73/download', {
headers: { 'X-Api-Key': vibeAppKey, Authorization: `Bearer ${b24AccessToken}` },
});
if (!response.ok) throw new Error(await response.text());
const bytes = await response.arrayBuffer();
Response
Binary bytes with Content-Type and Content-Disposition. For /v1/documents, the maximum file size is 10 MiB. Machine URLs in document reads lead to these authenticated V1 routes. PDF and PNG are generated asynchronously: for /v1/documents, retry 409 later. Bitrix24 credential URLs are never published.
Errors
| HTTP | Code | Condition |
|---|---|---|
| 400 | INVALID_PARAMS | Invalid document ID |
| 401 | TOKEN_MISSING | No Bitrix24 credential configured |
| 403 | SCOPE_DENIED | Missing the required route scope |
| 403 | ACCESS_DENIED | Bitrix24 denied access |
| 404 | ENTITY_NOT_FOUND | Document not found |
| 409 | DOCUMENT_NOT_READY | The /v1/documents representation is not ready; retry later |
| 422 | BITRIX_ERROR | Bitrix24 business refusal |
| 502 | DOWNLOAD_FAILED | Download failed, unsafe URL, invalid response or a /v1/documents file exceeds 10 MiB |