
## Search smart process items

`POST /v1/items/:entityTypeId/search`

Advanced item search with filtering, sorting, and auto-pagination. Supports up to 5000 records.

Use the `entityTypeId` field from [`GET /v1/smart-processes`](/docs/entities/smart-processes/list) in the `/v1/items/:entityTypeId` path. The type record's internal `id` is a different identifier. For example, if a type is returned as `{ "id": 3, "entityTypeId": 174 }`, the path starts with `/v1/items/174`. Use the returned value rather than assuming all type IDs start at 1030.

## Request fields (body)

| Parameter | Type | Description |
|----------|-----|---------|
| `filter` | object | Filtering by fields from `GET /v1/items/:entityTypeId/fields`.<br>[Filtering syntax](/docs/filtering). Example: `{ "filter": { "assignedById": 1 } }` |
| `sort` | string | Sorting. The `-` prefix means descending |
| `limit` | number | Number of records (default 50, max 5000) |
| `offset` | number | 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 |
| `select` | array | List of returned fields |
| `autoWindow` | boolean | Split the result set into weekly windows when filtering by a date range wider than 14 days. Defaults to `true`. `false` disables splitting |

### Filter syntax

Three formats are supported:

```json
{ "filter": { ">=opportunity": 100000 } }
{ "filter": { "opportunity": { "$gte": 100000 } } }
{ "filter": { "opportunity": { ">=": 100000 } } }
```

## Examples

The examples use `entityTypeId = 156`; replace it with the ID of your smart process.

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/items/156/search \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": {
      "assignedById": 1,
      "stageId": "DT156_41:NEW"
    },
    "select": ["id", "title", "opportunity", "stageId"],
    "sort": "-createdTime",
    "limit": 100
  }'
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/items/156/search \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": {
      "assignedById": 1,
      "stageId": "DT156_41:NEW"
    },
    "select": ["id", "title", "opportunity", "stageId"],
    "sort": "-createdTime",
    "limit": 100
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/items/156/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { assignedById: 1, stageId: 'DT156_41:NEW' },
    select: ['id', 'title', 'opportunity', 'stageId'],
    sort: '-createdTime',
    limit: 100,
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/items/156/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { assignedById: 1, stageId: 'DT156_41:NEW' },
    select: ['id', 'title', 'opportunity', 'stageId'],
    sort: '-createdTime',
    limit: 100,
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of items. All item fields — see [Item fields](/docs/entities/items/fields). With `select`, items carry only the listed fields |
| `meta.total` | number | How many records matched the filter. An optional field: if no count was requested, it is absent from the response |
| `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 page whose `data` length equals `limit` can still be the last one.

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

```
https://<portal>.bitrix24.com/crm/type/<entityTypeId>/details/<id>/
```

`<entityTypeId>` — the smart process type ID (the same as in the request path). `<portal>` — the Bitrix24 portal domain. If the smart process is placed in a separate section of your Bitrix24 account, Bitrix24 opens the card at the corresponding path. Access is restricted by the employee's permissions in Bitrix24.

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": 783,
      "title": "Supply contract",
      "stageId": "DT156_41:NEW",
      "opportunity": 500000
    }
  ],
  "meta": { "total": 5, "hasMore": false, "durationMs": 320 }
}
```

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

```json
{
  "success": true,
  "data": [ /* ... */ ],
  "meta": {
    "total": 8,
    "hasMore": true,
    "autoWindowed": true,
    "windowCount": 339,
    "batchWaves": 7,
    "durationMs": 15817
  }
}
```

## Error response example

403 — no scope:

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

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 403 | `SCOPE_DENIED` | The API key does not have the `crm` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 400 | `INVALID_DYNAMIC_PARAM` | `entityTypeId` is not a positive integer or is reserved (1, 2, 3, 4, 7, 31) |
| 400 | `UNKNOWN_FILTER_FIELD` | The filter field does not exist on the entity — the message lists the available fields |
| 400 | `UNKNOWN_SORT_FIELD` | The field in `sort` does not exist on the entity — the message lists the 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. Fetch 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 |
| 429 | `RATE_LIMITED` | Rate limit exceeded: 300 requests per minute per portal. All API keys of the portal share one limit. The current limit is returned in the `x-ratelimit-limit` header. Retry after the delay in the `Retry-After` header |

For the full list of common API errors, see [Errors](/docs/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`.

## See also

- [List items](/docs/entities/items/list)
- [Item fields](/docs/entities/items/fields)
- [Batch](/docs/batch)
- [Smart processes](/docs/entities/smart-processes)
- [Entity API](/docs/entity-api)
