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 by a filter passed in the request body. Equivalent to GET /v1/documents with filters, but the selection conditions are passed in the request body — which is more convenient for complex selections with a large number of conditions.
Request fields (body)
| Field | Type | Default | Description |
|---|---|---|---|
filter |
object | — | Selection by document fields. Filtering syntax. Example: { "filter": { "templateId": 53 } } |
limit |
number | 50 |
Number of documents in the response, up to 5000 |
offset |
number | 0 |
Skip 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 |
sort |
object | — | Sorting: { "id": "desc" }. The same fields as in filter are allowed |
select |
string[] | — | Field selection: ["id", "title", "number"]. The response keeps only the listed fields and id |
autoWindow |
boolean | true |
Split 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
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
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
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
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 |
|---|---|---|
success |
boolean | Always true on success |
data |
array | Array of documents (all fields — see Document fields) |
meta.total |
number | Number of documents matching the filter |
meta.hasMore |
boolean | Whether there are documents beyond limit |
meta.durationMs |
number | Request processing time in milliseconds |
meta.autoWindowed |
boolean | true if the result set was split into time windows |
meta.windowCount |
number | Number of windows. Present with autoWindowed: true |
meta.batchWaves |
number | Number of waves of parallel requests. Present with autoWindowed: true |
Response example
{
"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:
{
"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:
{
"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:
{
"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 |
|---|---|---|
| 400 | UNKNOWN_FILTER_FIELD |
A field in filter is not in the document field list |
| 400 | UNKNOWN_SORT_FIELD |
A field in sort is not in the document field list |
| 400 | UNSTABLE_OFFSET_PAGINATION |
offset 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 |
| 403 | SCOPE_DENIED |
The key is missing the documentgenerator scope |
| 401 | MISSING_API_KEY |
The X-Api-Key header was not provided |
Full list of common API errors — Errors.