Typical use-cases and scenarios of the document generator: case overview
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
Scope:
documentgeneratorWho can execute the method: a user with document creation permissions
A template in the document generator is a .docx file with placeholders for fields that are replaced with data from the request when creating the document. Placeholders are formatted in curly braces, such as {DocumentNumber} or {MyField}. For more details, refer to the article Document Generator Templates: Overview of Methods.
The cases help prepare data for document creation based on the template using the documentgenerator.document.add method. After creating the document, you can obtain links to the files and continue working with the results using methods from the Document Generator: Overview of Methods section.
Quick navigation: all cases
Getting Started
- Prepare a
.docxtemplate with field placeholders. - Retrieve the field map of the template using the documentgenerator.template.getfields method.
- Determine which data needs to be passed in
valuesandfieldsfor the documentgenerator.document.add method.values— what to insert into the document.fields— how to interpret this data: field type, format, image, print, table, or repeating block.
- Open the example that is closest to your scenario and adapt it to your template.
What Is Returned in the Response
All cases end with a call to documentgenerator.document.add, so their response is the same: a document object with the document identifier, its number, and links to the files.
id— document identifier for further callsdownloadUrlanddownloadUrlMachine— DOCX download links for the user and for the applicationisTransformationError— flag indicating a conversion error
The pdfUrl and imageUrl fields are returned in the response only after the PDF and the document image have been generated. The conversion is performed asynchronously, so these fields are usually absent immediately after creation — check them with the documentgenerator.document.get method.
If the request fails, the method returns an error.
{
"error": "0",
"error_description": "Cannot create document on deleted template"
}
A complete description of the response fields and the list of errors is available on the page of the documentgenerator.document.add method. Each case covers only the errors typical of its scenario.
Case Overview
|
Case |
Description |
|
Inserts text values without additional field type settings |
|
|
Formats date and name through |
|
|
Fills rows of a single table with a repeating structure |
|
|
Works with nested tables and multiple repeating blocks |
|
|
Inserts images, seals, and signatures via external links |