Document Generator: Overview of Methods and Events

The document generator in CRM allows you to prepare a template, configure a numbering system, create a document from a template, or upload a ready-made file. It supports deals, leads, contacts, companies, invoices, estimates, and elements of Smart Process Automation (SPA).

The section consists of three main parts. In Numerators, you configure the number template and counter. In Document Templates, you upload a .docx file, link it to the numerator, region, and types of CRM entities. In Documents, you create a document from a template or upload a ready-made file, obtain links to the file, include a public link, and modify or delete the document.

For example, you can create a numerator for deals, link it to the deal template, and then create documents for specific deals.

If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect the MCP server so that the assistant uses the official REST documentation.

Quick navigation: all methods and events

User documentation:

Getting Started

  1. Create a numerator using the method crm.documentgenerator.numerator.add — this sets the number template for documents.
  2. Prepare a .docx template file in Base64 format — How to upload files.
  3. Define the entityTypeId of the required CRM entity — typical values are provided in the article Features of transmitted values.
  4. Upload the template using the method crm.documentgenerator.template.add: pass the name, file, numeratorId, entityTypeId, and region.
  5. Obtain the entityId of the required CRM entity using the method crm.item.list.
  6. Choose how to work with the document:

Important Considerations

  • When creating a document from a template, the link between the template and the Sales Funnel is not automatically checked — the document is created even if the template is configured for a different funnel.
  • The pdfUrl and imageUrl links may be absent immediately after creating or updating the document, as conversion is performed asynchronously. If you need the links right away, repeat the request using the method crm.documentgenerator.document.get after 30-40 seconds.

Relationships with Other Objects

Numerators. The numerator sets the number template and counter for documents. The document template uses it via the numeratorId parameter. If you are creating a new numerator, take the id from the response of crm.documentgenerator.numerator.add. If you are using an existing one, obtain the id using the method crm.documentgenerator.numerator.list.

Document Templates. The template stores the .docx file, region, linkage to types of CRM entities, and connection with the numerator. To create a document, you need the templateId — take the id from the response of crm.documentgenerator.template.add or the id of the required template from the response of crm.documentgenerator.template.list.

Documents. A document is created from a template using the method crm.documentgenerator.document.add or a ready-made file is uploaded using the method crm.documentgenerator.document.upload — in both cases, the document is attached to a CRM entity.

CRM Entities. Templates and documents use entityTypeId and entityId. Typical values of entityTypeId for CRM entities are provided in the article Features of transmitted values. For Smart Processes, entityTypeId can be obtained using the method crm.type.list. The identifier of the required object entityId is obtained using the method crm.item.list.

Regions. The template is linked to the country via the region parameter. The region value is passed in the method crm.documentgenerator.template.add, for example, de. A list of available regions can be obtained using the method documentgenerator.region.list.

Files. Templates use a .docx file, and in the method crm.documentgenerator.document.upload, the content of the ready-made DOCX file is passed in Base64. The upload format is described in the article How to upload files.

Overview of Methods and Events

Scope: crm

Who can perform the method: depends on the method

Numerators

Method

Description

crm.documentgenerator.numerator.add

Adds a new numerator

crm.documentgenerator.numerator.update

Updates an existing numerator

crm.documentgenerator.numerator.get

Returns information about the numerator by identifier

crm.documentgenerator.numerator.list

Returns a list of numerators

crm.documentgenerator.numerator.delete

Deletes a numerator

Document Templates

Method

Description

crm.documentgenerator.template.add

Adds a new template

crm.documentgenerator.template.update

Updates an existing template

crm.documentgenerator.template.get

Returns information about the template by identifier

crm.documentgenerator.template.list

Returns a list of templates

crm.documentgenerator.template.delete

Deletes a template

crm.documentgenerator.template.getfields

Returns the fields of the template for the specified CRM entity

Documents

Method

Description

crm.documentgenerator.document.add

Creates a document from a template

crm.documentgenerator.document.update

Updates a document

crm.documentgenerator.document.get

Returns information about the document

crm.documentgenerator.document.list

Returns a list of documents

crm.documentgenerator.document.delete

Deletes a document

crm.documentgenerator.document.enablepublicurl

Enables or disables the public link

crm.documentgenerator.document.upload

Uploads a ready document and attaches it to a CRM entity

crm.documentgenerator.document.getfields

Returns the fields of the created document

Event

Triggered

onCrmDocumentGeneratorDocumentAdd

When generating a document manually or using the method crm.documentgenerator.document.add

onCrmDocumentGeneratorDocumentUpdate

When modifying a document manually or using the method crm.documentgenerator.document.update

onCrmDocumentGeneratorDocumentDelete

When deleting a document manually or using the method crm.documentgenerator.document.delete