
## Search order statuses

`POST /v1/order-statuses/search`

Search statuses with filtering. Equivalent to [`GET /v1/order-statuses`](./list.md), but the filter conditions are passed in the request body — this lets you specify several conditions at once.

## Request fields (body)

| Parameter | Type | Default | Description |
|----------|-----|-----------|---------|
| `filter` | object | — | Filtering by status fields.<br>[Filtering syntax](/docs/filtering) |
| `limit` | number | `50` | Number of records (up to 5000) |
| `select` | string[] | — | Field selection: `["id", "type", "sort", "color"]` |
| `order` | object | — | Sorting: `{ "sort": "asc" }` |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/order-statuses/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "type": "O", "notify": true },
    "select": ["id", "type", "sort", "color"]
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/order-statuses/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "type": "O", "notify": true },
    "select": ["id", "type", "sort", "color"]
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/order-statuses/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { type: 'O', notify: true },
    select: ['id', 'type', 'sort', 'color'],
  }),
})

const { success, data, meta } = await res.json()
console.log('Statuses with notification:', meta.total)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/order-statuses/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { type: 'O', notify: true },
    select: ['id', 'type', 'sort', 'color'],
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of statuses |
| `meta.total` | number | Total number of records matching the filter |
| `meta.hasMore` | boolean | Whether there are more records beyond `limit` |
| `meta.durationMs` | number | Request duration in 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.

## Response example

```json
{
  "success": true,
  "data": [
    { "id": "T", "type": "O", "sort": 30, "color": "#ACE9FB" },
    { "id": "N", "type": "O", "sort": 100, "color": "#ACE9FB" },
    { "id": "S", "type": "O", "sort": 110, "color": "#ACE9FB" },
    { "id": "P", "type": "O", "sort": 130, "color": "#ACE9FB" },
    { "id": "D", "type": "O", "sort": 140, "color": "#FFBEBD" },
    { "id": "F", "type": "O", "sort": 200, "color": "#DBF199" }
  ],
  "meta": {
    "total": 6,
    "hasMore": false,
    "durationMs": 300
  }
}
```

## Error response example

400 — filter by a nonexistent field:

```json
{
  "success": false,
  "error": {
    "code": "UNKNOWN_FILTER_FIELD",
    "message": "Unknown filter field 'foo' for entity 'order-statuses'. Available: id, type, sort, notify, color, xmlId"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `UNKNOWN_FILTER_FIELD` | Filter by a field that is not in the status schema |
| 403 | `SCOPE_DENIED` | The API key does not have the `sale` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

Full list of general API errors — [Errors](/docs/errors).

## Known specifics

**`select` limits the fields in the response.** If `select` is passed, each element of `data[]` will have only the listed fields. Without `select`, all status fields are returned.

## See also

- [List statuses](./list.md)
- [Get status](./get.md)
- [Status fields](./fields.md)
- [Orders in this status](../orders/list.md)
- [Filtering syntax](/docs/filtering)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
