لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/crm-document-templates/download.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Download a CRM document template
GET /v1/crm-document-templates/:id/download
Downloads the source .docx file of a CRM document template through Vibecode: the platform adds Bitrix24 authorization to the request for you.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Parameterid (path) |
Typenumber | Requiredyes | DescriptionTemplate ID. List: GET /v1/crm-document-templates |
The request has no body.
Examples
curl — personal key
curl -H "X-Api-Key: YOUR_API_KEY" \
"https://vibecode.bitrix24.com/v1/crm-document-templates/87/download" \
-o template-87.docx
curl — OAuth application
curl -H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
"https://vibecode.bitrix24.com/v1/crm-document-templates/87/download" \
-o template-87.docx
JavaScript — personal key
const res = await fetch(
'https://vibecode.bitrix24.com/v1/crm-document-templates/87/download',
{ headers: { 'X-Api-Key': 'YOUR_API_KEY' } }
)
if (!res.ok) {
const body = await res.json()
throw new Error(body.error?.code ?? String(res.status))
}
const blob = await res.blob()
JavaScript — OAuth application
const res = await fetch(
'https://vibecode.bitrix24.com/v1/crm-document-templates/87/download',
{
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
}
)
if (!res.ok) {
const body = await res.json()
throw new Error(body.error?.code ?? String(res.status))
}
const blob = await res.blob()
Response headers
On success, the response has HTTP status 200 OK, and the body contains the bytes of the .docx file.
| Header | Example value | Description |
|---|---|---|
HeaderContent-Type |
Example valueapplication/vnd.openxmlformats-officedocument.wordprocessingml.document |
DescriptionContent type that Bitrix24 returned for the template file |
HeaderContent-Disposition |
Example valueattachment; filename="template-87.docx" |
DescriptionFile name for saving. Built from the template id as template-<id>.docx; the template name is not part of it |
Response example
HTTP/1.1 200 OK
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Disposition: attachment; filename="template-87.docx"
Transfer-Encoding: chunked
<binary .docx content, 10872 bytes, starts with PK>
Error response example
404 — template not found:
{
"success": false,
"error": {
"code": "ENTITY_NOT_FOUND",
"message": "CRM template not found."
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
Descriptionid is not a positive integer. Message: Template ID must be a positive integer. |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionNo template with this id exists, or it does not belong to the CRM module. Message: CRM template not found. |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionThe template exists but has no download URL. Message: CRM template download not found. |
| HTTP502 | CodeDOWNLOAD_FAILED |
DescriptionBitrix24 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 |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 rejected the request to read the template. The reason is in error.message |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key lacks the crm scope |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe key has no configured tokens |
| HTTP429 | CodeRATE_LIMITED |
DescriptionBitrix24 rate-limited requests to the portal. Retry after the delay in the Retry-After header |
Full list of common API errors — Errors.
Known specifics
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.
The downloadMachine field points here. In the responses of GET /v1/crm-document-templates/:id and GET /v1/crm-document-templates, this field contains the URL of this endpoint.