For AI agents: markdown of this page — /docs-content-en/entities/doc-templates/search.md documentation index — /llms.txt

Search templates

POST /v1/doc-templates/search

Returns the Bitrix24 account's document templates by the filter passed in the request body. For selections up to 5000 records use GET /v1/doc-templates with parameters in the query string.

Request fields (body)

Field Type Default Description
filter object Filter by template fields. Field list — GET /v1/doc-templates/fields.
Filtering syntax. Example: {"filter": {"active": "Y"}}
select string[] Field selection: ["id", "name", "region"]
sort object Sort by field: {"sort": {"id": "desc"}}
limit number 50 Number of records (up to 5000)
offset number 0 Offset for pagination

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/doc-templates/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "region": "us", "active": "Y" },
    "limit": 10,
    "select": ["id", "name", "region", "active"]
  }'

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/doc-templates/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "region": "us", "active": "Y" },
    "limit": 10,
    "select": ["id", "name", "region", "active"]
  }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/doc-templates/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { region: 'us', active: 'Y' },
    limit: 10,
    select: ['id', 'name', 'region', 'active'],
  }),
})

const { success, data, meta } = await res.json()
console.log(`Found ${meta.total} templates`)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/doc-templates/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { region: 'us', active: 'Y' },
    limit: 10,
    select: ['id', 'name', 'region', 'active'],
  }),
})

const { success, data, meta } = await res.json()

Response fields

Field Type Description
success boolean Always true on success
data array Array of templates
data[].id number Template identifier
data[].name string Name
data[].active string Availability: Y / N
data[].code string | null System code of the template
data[].region string Region
data[].sort number Order in the list
data[].createTime string Creation date (ISO 8601)
data[].updateTime string Change date (ISO 8601)
data[].createdBy number Identifier of the employee who created it
data[].updatedBy number | null Identifier of the employee who changed it
data[].moduleId string Source module of the template
data[].fileId number Disk file identifier
data[].bodyType string Document body format
data[].numeratorId number Numerator identifier
data[].withStamps string Stamps and signatures: Y / N
data[].productsTableVariant string Products table variant in the document
data[].isDeleted boolean Whether the template is marked deleted
data[].isDefault string Default template: Y / N
data[].users array Identifiers of employees who have access to the template
data[].download string Document download URL
data[].downloadMachine string Download URL for programmatic access
meta.total number Number of records matching the filter
meta.hasMore boolean Whether there are more records beyond limit
meta.durationMs number Server-side request execution time, milliseconds

The meta fields sit next to data, not inside it. Pages must be walked by meta.hasMore: a data length equal to limit does not rule out the last page.

Full template field schema — Template fields.

Response example

JSON
{
  "success": true,
  "data": [
    {
      "id": 209,
      "active": "Y",
      "name": "Contract template",
      "code": null,
      "region": "us",
      "sort": 500,
      "createTime": "2026-05-12T09:03:38.000Z",
      "updateTime": "2026-05-12T09:03:38.000Z",
      "createdBy": 1,
      "updatedBy": null,
      "moduleId": "rest",
      "fileId": 9175,
      "bodyType": "Bitrix\\DocumentGenerator\\Body\\Docx",
      "numeratorId": 1,
      "withStamps": "N",
      "productsTableVariant": "",
      "isDeleted": false,
      "isDefault": "N",
      "users": ["U1"],
      "download": "/bitrix/services/main/ajax.php?action=documentgenerator.api.template.download&SITE_ID=s1&id=209",
      "downloadMachine": "https://<portal>/rest/1/<token>/documentgenerator.api.template.download/?token=<token>"
    },
    {
      "id": 211,
      "active": "Y",
      "name": "Invoice template",
      "code": null,
      "region": "us",
      "sort": 500,
      "createTime": "2026-05-12T09:04:38.000Z",
      "updateTime": "2026-05-12T09:04:38.000Z",
      "createdBy": 1,
      "updatedBy": null,
      "moduleId": "rest",
      "fileId": 5901,
      "bodyType": "Bitrix\\DocumentGenerator\\Body\\Docx",
      "numeratorId": 1,
      "withStamps": "N",
      "productsTableVariant": "",
      "isDeleted": false,
      "isDefault": "N",
      "users": ["U1"],
      "download": "/bitrix/services/main/ajax.php?action=documentgenerator.api.template.download&SITE_ID=s1&id=211",
      "downloadMachine": "https://<portal>/rest/1/<token>/documentgenerator.api.template.download/?token=<token>"
    }
  ],
  "meta": {
    "total": 2,
    "hasMore": false,
    "durationMs": 799
  }
}

Error response example

400 — filter by a nonexistent field. The message lists the fields available for filtering:

JSON
{
  "success": false,
  "error": {
    "code": "UNKNOWN_FILTER_FIELD",
    "message": "Unknown filter field 'bogusField' for entity 'doc-templates'. Available: id, name, numeratorId, region, code, moduleId, active, bodyType, withStamps, sort, users, fileId, file, createdBy, updatedBy, isDeleted, createTime, updateTime, download, downloadMachine, providers, isDefault, productsTableVariant"
  }
}

Errors

HTTP Code Description
400 UNKNOWN_FILTER_FIELD Filter by a nonexistent field; the message lists the available fields
400 UNKNOWN_SORT_FIELD Sort by a nonexistent field in sort; the message lists the available fields
403 SCOPE_DENIED The key lacks the documentgenerator scope
401 TOKEN_MISSING The key has no configured tokens

Full list of common API errors — Errors.

Known specifics

Sorting and pagination happen on the Vibecode side. sort ({"sort": {"field": "asc|desc"}}) and offset/limit are applied on the Vibecode side: the full set is fetched, sorted, and sliced to the requested window; total and hasMore are computed from the collected set.

String sorting is byte-wise. Sorting by string fields (name, region) compares strings byte by byte, with no locale or case awareness. Numeric (id, sort) and datetime (createTime, updateTime) fields sort correctly. Empty values (null / empty string) always sort to the end.

See also