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

Search documents

POST /v1/documents/search

Returns documents matching a filter passed in the request body. Equivalent to GET /v1/documents with filters, but the conditions go in the request body — more convenient for complex requests with many conditions.

Request fields (body)

Field Type Default Description
Fieldfilter Typeobject Default— DescriptionFiltering by document fields.
Filtering syntax. Example: { "filter": { "templateId": 53 } }
Fieldlimit Typenumber Default50 DescriptionNumber of documents in the response, up to 5000
Fieldoffset Typenumber Default0 DescriptionSkip the specified number of documents. Together with a date-range filter wider than 14 days it is rejected — see UNSTABLE_OFFSET_PAGINATION in the "Errors" section
Fieldsort Typeobject Default— DescriptionSorting: { "id": "desc" }. The same fields as in filter are allowed
Fieldselect Typestring[] Default— DescriptionField selection: ["id", "title", "number"]. The response keeps only the listed fields and id
FieldautoWindow Typeboolean Defaulttrue DescriptionSplit the result set into weekly windows when filtering by a date range wider than 14 days. false disables splitting

Field names for filter, sort, and select come from Document fields.

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/documents/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "templateId": 53 },
    "limit": 10,
    "sort": { "id": "desc" }
  }'

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/documents/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "templateId": 53 },
    "limit": 10,
    "sort": { "id": "desc" }
  }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/documents/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { templateId: 53 },
    limit: 10,
    sort: { id: 'desc' },
  }),
})

const { data, meta } = await res.json()
console.log('Found:', meta.total)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/documents/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { templateId: 53 },
    limit: 10,
    sort: { id: 'desc' },
  }),
})

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

Response fields

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata Typearray DescriptionArray of documents (all fields — see Document fields)
Fieldmeta.total Typenumber DescriptionNumber of documents matching the filter
Fieldmeta.hasMore Typeboolean DescriptionWhether there are more records beyond limit
Fieldmeta.durationMs Typenumber DescriptionRequest processing time in milliseconds
Fieldmeta.autoWindowed Typeboolean Descriptiontrue if the result set was split into time windows
Fieldmeta.windowCount Typenumber DescriptionNumber of windows. Present with autoWindowed: true
Fieldmeta.batchWaves Typenumber DescriptionNumber of parallel request waves. Present with autoWindowed: true

Response example

JSON
{
  "success": true,
  "data": [
    {
      "id": 51,
      "title": "Supply contract 2026-001",
      "number": "2026-001",
      "templateId": 53,
      "provider": "Bitrix\\DocumentGenerator\\DataProvider\\Rest",
      "value": "ORDER-1024",
      "createTime": "2026-03-18T17:27:48+00:00",
      "updateTime": "2026-03-18T17:27:48+00:00",
      "createdBy": 503,
      "updatedBy": null,
      "values": { "DocumentNumber": "2026-001" },
      "stampsEnabled": false,
      "pdfUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=documentgenerator.api.document.getpdf&id=51"
    }
  ],
  "meta": { "total": 1, "hasMore": false, "durationMs": 42 }
}

When no document matches the filter, data comes back as an empty array and meta.total is 0:

JSON
{
  "success": true,
  "data": [],
  "meta": { "total": 0, "hasMore": false, "durationMs": 644 }
}

With a date-range filter wider than 14 days, meta additionally returns autoWindowed, windowCount, and batchWaves:

JSON
{
  "success": true,
  "data": [],
  "meta": {
    "total": 0,
    "hasMore": false,
    "autoWindowed": true,
    "windowCount": 339,
    "batchWaves": 7,
    "durationMs": 7890
  }
}

Error response example

400 — a field in filter is not in the document field list:

JSON
{
  "success": false,
  "error": {
    "code": "UNKNOWN_FILTER_FIELD",
    "message": "Unknown filter field 'notArealField' for entity 'documents'."
  }
}

Known specifics

A field name in filter and sort is validated against the document field list before the data is accessed. An unknown field in filter returns 400 UNKNOWN_FILTER_FIELD, an unknown field in sort returns 400 UNKNOWN_SORT_FIELD; in both cases the message lists the allowed field names.

Time-window splitting. A date-range filter wider than 14 days (the createTime or updateTime fields) is automatically split into weekly windows executed in parallel waves, so the result set bypasses the ceiling of 5000 documents per call. meta then returns autoWindowed: true, the number of windows windowCount, and the number of waves batchWaves. The autoWindow: false parameter disables splitting. While splitting is active, an offset greater than zero is rejected with UNSTABLE_OFFSET_PAGINATION.

Errors

HTTP Code Description
HTTP400 CodeUNKNOWN_FILTER_FIELD DescriptionA field in filter is not in the document field list
HTTP400 CodeUNKNOWN_SORT_FIELD DescriptionA field in sort is not in the document field list
HTTP400 CodeUNSTABLE_OFFSET_PAGINATION Descriptionoffset greater than zero together with a date-range filter wider than 14 days. Two different retrieval algorithms produce inconsistent results, so the request is rejected. Take everything in a single request with limit up to 5000, or pass autoWindow: false with sorting by id, or split the date range into parts yourself
HTTP403 CodeSCOPE_DENIED DescriptionThe key is missing the documentgenerator scope
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header was not provided
HTTP429 CodeRATE_LIMITED DescriptionRate limit exceeded: 300 requests per minute per portal, all API keys of the portal share one limit. The exact value arrives in the x-ratelimit-limit header (the cap is divided across replicas). Retry after the delay in the Retry-After header

Full list of common API errors — Errors.

See also