Document Templates: Overview of Methods

A document template is a .docx file with placeholders that are populated with data from the CRM during generation. Each template is associated with a number generator and one or more types of CRM entities.

The template is uploaded via the API once. After that, it is used for each document generation: the template ID and a specific CRM entity—deal, contact, invoice, or Smart Process entity—are passed to the document creation method.

For example, a commercial estimate template can be linked to deals in the Sales Funnel 2_category_0—when generating, the deal's data and the number from the number generator will be included in the document.

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

Quick navigation: all methods

User documentation:

Getting Started

  1. Prepare the template file in .docx format—How to Upload Files.
  2. Create a number generator or take the ID of an existing one—using methods from the Number Generators section.
  3. Upload the template using the crm.documentgenerator.template.add method: pass the file, numeratorId, region, and entityTypeId.
  4. Check the template fields using the crm.documentgenerator.template.getfields method if you need to verify the substitutions for a specific entity.
  5. Create a document from the template using the crm.documentgenerator.document.add method, passing templateId, entityTypeId, and entityId of the specific CRM entity.

Linking with Other Entities

Number Generators. The template is linked to a number generator through the numeratorId parameter. If you are creating a new number generator, take the id from the response of crm.documentgenerator.numerator.add. If you are using an existing one, obtain the id using the crm.documentgenerator.numerator.list method.

Documents. The template serves as a basis for generating documents. When creating a document using the crm.documentgenerator.document.add method, the templateId, entityTypeId, and entityId of the specific CRM entity are passed to the method.

CRM Entities. The template is linked to one or more types of entities through entityTypeId. Typical values for CRM entities are provided in the article Features of Passed Values, and for Smart Processes, entityTypeId can be obtained using the crm.type.list method. To specify the funnel, a suffix is added to the identifier, for example, 2_category_0.

Overview of Methods

Scope: crm

Who can execute the method: a user with the "modify" permission for document generator 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 ID

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