
## Search sections

`POST /v1/catalog-sections/search`

Search catalog sections by conditions passed in the request body.

Unlike [`GET /v1/catalog-sections`](./list.md), the `filter`, `select`, `sort`, `limit`, and `offset` parameters are passed in the JSON body rather than in the URL query string — conditions across several fields are expressed as a nested structure. Like the list, search requires `filter.iblockId` — without this field the request returns `400`. The response format is the same as for the list.

## Request fields (body)

| Parameter | Type | Req. | Default | Description |
|----------|-----|:-----:|-----------|---------|
| `filter` | object | yes | — | Filtering conditions. The `iblockId` key is required — the catalog ID from [`GET /v1/catalogs`](/docs/entities/catalogs).<br>[Filtering syntax](/docs/filtering). Example: `{ "iblockId": 25, "active": true }` |
| `select` | string[] | no | — | Field selection: `["id", "name", "sort"]`. Only the listed fields are returned |
| `sort` | string | no | — | Sort field. The `-` prefix means descending: `"-sort"` |
| `limit` | number | no | `50` | Number of records (up to 5000) |
| `offset` | number | no | `0` | Offset from the start of the selection |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/catalog-sections/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "iblockId": 25, "active": true },
    "limit": 2
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/catalog-sections/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "iblockId": 25, "active": true },
    "limit": 2
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/catalog-sections/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { iblockId: 25, active: true },
    limit: 2,
  }),
})

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/catalog-sections/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { iblockId: 25, active: true },
    limit: 2,
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of sections |
| `data[].id` | number | Section identifier |
| `data[].iblockId` | number | ID of the catalog the section belongs to |
| `data[].iblockSectionId` | number \| null | ID of the parent section. `null` — top-level section |
| `data[].name` | string | Section name |
| `data[].code` | string \| null | Symbolic code of the section |
| `data[].xmlId` | string \| null | External identifier |
| `data[].sort` | number | Sort index |
| `data[].active` | boolean | Whether the section is active |
| `data[].description` | string \| null | Section description |
| `data[].descriptionType` | string | Description format: `text` or `html` |
| `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": [
    {
      "active": true,
      "code": "clothes",
      "description": null,
      "descriptionType": "text",
      "iblockId": 25,
      "iblockSectionId": null,
      "id": 31,
      "name": "Clothing",
      "sort": 50,
      "xmlId": null
    },
    {
      "active": true,
      "code": "shoes",
      "description": null,
      "descriptionType": "text",
      "iblockId": 25,
      "iblockSectionId": 31,
      "id": 35,
      "name": "Footwear",
      "sort": 100,
      "xmlId": null
    }
  ],
  "meta": {
    "total": 37,
    "hasMore": true,
    "durationMs": 165
  }
}
```

## Error response example

400 — filter on a non-existent field:

```json
{
  "success": false,
  "error": {
    "code": "UNKNOWN_FILTER_FIELD",
    "message": "Unknown filter field 'bogus' for entity 'catalog-sections'. Available: id, iblockId, iblockSectionId, name, xmlId, code, sort, active, description, descriptionType"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `MISSING_REQUIRED_FILTER` | The required `filter.iblockId` filter was not passed. The request is rejected before Bitrix24 is called — the message contains the name of the missing field and a request body example |
| 400 | `UNKNOWN_FILTER_FIELD` | Filter on a field the section does not have. The message contains the list of available fields |
| 403 | `SCOPE_DENIED` | The API key does not have the `catalog` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |

For the full list of common API errors, see [Errors](/docs/errors).

## See also

- [List sections](/docs/entities/catalog-sections/list)
- [Create section](/docs/entities/catalog-sections/create)
- [Get section](/docs/entities/catalog-sections/get)
- [Section fields](/docs/entities/catalog-sections/fields)
- [Filtering syntax](/docs/filtering)
- [Entities reference](/docs/entities-index)
