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

Search deals

POST /v1/deals/search

Search deals with filters and auto-pagination. Equivalent to GET /v1/deals with filters, but via POST — more convenient for complex requests with many conditions.

Request fields (body)

Parameter Type Default Description
filter object Filter by the fields from GET /v1/deals/fields.
Filtering syntax. Example: ?filter[stageId]=NEW
limit number 50 Number of records (up to 5000)
offset number 0 Skip N records. Combined with a date-range filter wider than 14 days, the request is rejected — see UNSTABLE_OFFSET_PAGINATION in the "Errors" section
order object Sorting: { "createdAt": "desc" }
select string[] Field selection: ["id", "title", "amount"]
autoWindow boolean true Split the result set into weekly windows when filtering by a date range wider than 14 days. false disables splitting

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/deals/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "stageId": "NEW" },
    "limit": 10,
    "order": { "amount": "desc" }
  }'

curl — OAuth app

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/deals/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "stageId": "NEW" },
    "limit": 10,
    "order": { "amount": "desc" }
  }'

JavaScript — personal key

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

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

JavaScript — OAuth app

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

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

Response fields

Field Type Description
data array Array of deals (all fields — see Fields)
meta.total number How many records matched the filter
meta.hasMore boolean Whether there are more records beyond limit
meta.nextAfterId string The identifier of the last returned record. Returned when the sort is strictly id ascending, while hasMore is true. Pass it back in the >id filter — a cheap replacement for a growing offset
meta.durationMs number Request duration 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 parallel request waves. Present with autoWindowed: true

The meta fields sit next to data, not inside it. Paginate using meta.hasMore: a data length equal to limit does not rule out the last page.

The card URL of any deal from the data array is built from its id:

https://<portal>.bitrix24.com/crm/deal/details/<id>/

<portal> — the Bitrix24 portal domain. Access is restricted by the employee's permissions in Bitrix24.

Response example

JSON
{
  "success": true,
  "data": [
    {
      "id": 3865,
      "title": "Template",
      "amount": 0,
      "currency": "USD",
      "stageId": "NEW",
      "categoryId": 0,
      "assignedById": 29,
      "createdAt": "2021-01-13T13:52:44.000Z"
    }
  ],
  "meta": {
    "total": 1915,
    "hasMore": true,
    "durationMs": 690
  }
}

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

JSON
{
  "success": true,
  "data": [ /* ... */ ],
  "meta": {
    "total": 618,
    "hasMore": true,
    "autoWindowed": true,
    "windowCount": 78,
    "batchWaves": 2,
    "durationMs": 2742
  }
}

Error response example

403 — no scope:

JSON
{
  "success": false,
  "error": {
    "code": "SCOPE_DENIED",
    "message": "This endpoint requires 'crm' scope"
  }
}

Errors

HTTP Code Description
400 UNKNOWN_FILTER_FIELD Filter on a field absent from the deal schema. The message contains the list of available fields
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 API key lacks the crm scope
401 TOKEN_MISSING API key has no configured tokens
429 RATE_LIMITED Rate 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.

Known specifics

Time-window splitting. A date-range filter wider than 14 days is automatically split into weekly windows executed in parallel waves, so the result set bypasses the ceiling of 5000 records 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.

Reports on closed deals are filtered by closedAt. A deal's closing date is the closedAt field (ISO 8601 in the Bitrix24 account's time zone), filled in when the deal moves to a final stage. The field name is exactly closedAt — not closedDate. For a "won/lost over a period" report, filter by the closedAt range:

JSON
{
  "filter": {
    "closedAt": { "$gte": "2026-01-01", "$lte": "2026-01-31T23:59:59" }
  }
}

To separate won from lost deals, add the stage (stageId) to the filter. Get the identifiers of the pipeline's final stages from GET /v1/statuses?filter[entityId]=DEAL_STAGE.

See also