Untuk ejen AI: markdown halaman ini — /docs-content-en/entities/documents.md indeks dokumentasi — /llms.txt

Artikel dokumentasi kini tersedia dalam bahasa Inggeris.

Documents

A document is a ready-to-use file that Bitrix24 generates from a template by substituting values. Each document is created from a document template and a data provider.

Bitrix24 API: documentgenerator.document.* Scope: documentgenerator

For CRM documents, select a template in the CRM template section; app templates live in /v1/doc-templates. The /v1/crm-documents routes use crm.documentgenerator.document.* and the crm scope.

PDF and PNG are generated asynchronously. Retry a download after 409 DOCUMENT_NOT_READY. Machine download links use /v1/documents with documentgenerator scope for app documents, and /v1/crm-documents with crm scope for CRM documents. Public sharing is a separate action: an enabled public URL works without authentication.

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

Terminal
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

Terminal
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

javascript
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

javascript
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

Common errors

See also