## Search units of measure

`POST /v1/catalog-measures/search`

Searches product catalog units of measure by conditions passed in the request body as a JSON object.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|-------|----------|
| `filter` | object | no | Filtering by the fields from `GET /v1/catalog-measures/fields`.<br>[Filtering syntax](/docs/filtering). Example: `{"isDefault": "N"}` |
| `sort` | string \| object \| array | no | Sorting as a string `"-code"`, where the minus means descending, as an object `{"code": "desc"}`, or as an array of strings `["-code"]`. If omitted, records are sorted by `id` in ascending order |
| `order` | object | no | Synonym of `sort` in object form: `{"code": "desc"}` |
| `select` | string[] | no | Field selection: `["id", "code"]`. A comma-separated string is also accepted: `"id,code"` |
| `limit` | number | no | Number of records, from 1 to 5000. Default `50` |
| `offset` | number | no | Skip N records. Default `0` |
| `autoWindow` | boolean | no | Split the result set into date windows. The unit of measure schema has no date fields, so the value does not affect the result |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/catalog-measures/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "isDefault": "N" },
    "sort": "-code",
    "limit": 2
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/catalog-measures/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "isDefault": "N" },
    "sort": "-code",
    "limit": 2
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/catalog-measures/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { isDefault: 'N' },
    sort: '-code',
    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-measures/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { isDefault: 'N' },
    sort: '-code',
    limit: 2,
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of units of measure |
| `data[].id` | number | Unit identifier. Pass it in the product's `measure` field |
| `data[].code` | number | Unit code in the Russian National Classifier of Units of Measurement (OKEI) |
| `data[].measureTitle` | string \| null | Unit of measure name |
| `data[].symbol` | string \| null | Short symbol |
| `data[].symbolIntl` | string \| null | International symbol |
| `data[].symbolLetterIntl` | string \| null | International letter code |
| `data[].isDefault` | string | Default unit: `Y` or `N` |
| `meta.total` | number | Number of records matching the filter |
| `meta.hasMore` | boolean | Whether there are more records beyond `limit` |
| `meta.durationMs` | number | Request duration in milliseconds |
| `meta.warnings` | array | Request parsing warnings. Present when `select` contains a name outside the schema (code `UNKNOWN_SELECT_FIELD`) or when `limit: 0` is passed (code `LIMIT_ZERO_IGNORED`: the value is ignored and the default page is returned) |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "code": 166,
      "id": 7,
      "isDefault": "N",
      "measureTitle": null,
      "symbol": null,
      "symbolIntl": "kg",
      "symbolLetterIntl": "KGM"
    },
    {
      "code": 163,
      "id": 5,
      "isDefault": "N",
      "measureTitle": null,
      "symbol": null,
      "symbolIntl": "g",
      "symbolLetterIntl": "GRM"
    }
  ],
  "meta": {
    "total": 5,
    "hasMore": true,
    "durationMs": 192
  }
}
```

## Error response example

400 — sorting by a field that is not in the schema:

```json
{
  "success": false,
  "error": {
    "code": "UNKNOWN_SORT_FIELD",
    "message": "Unknown sort field 'nope' for entity 'catalog-measures'. Available: id, code, measureTitle, symbol, symbolIntl, symbolLetterIntl, isDefault"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `UNKNOWN_FILTER_FIELD` | Filtering by a field that is not in the unit of measure schema. The message lists the available fields |
| 400 | `UNKNOWN_SORT_FIELD` | Sorting by a field that is not in the schema. The message lists the available fields |
| 400 | `INVALID_FILTER_OPERATOR` | Unknown operator in a filter condition, for example `$foo`. The message lists the supported operators |
| 400 | `INVALID_FILTER_OPERATOR` | A logical key `$or`, `$and`, or `$not` in the filter. For an OR condition on one field, use the `$in` operator. For an OR across different fields, send parallel requests via [`POST /v1/batch`](/docs/batch) |
| 400 | `INVALID_SORT_TYPE` | `sort` is not a string, an object, or an array of strings |
| 400 | `INVALID_SELECT_TYPE` | `select` is not a string or an array of strings |
| 400 | `INVALID_LIMIT` | `limit` is not a number |
| 403 | `SCOPE_DENIED` | The API key lacks the `catalog` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 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](/docs/errors).

## See also

- [List units of measure](/docs/entities/catalog-measures/list)
- [Get a unit of measure](/docs/entities/catalog-measures/get)
- [Unit of measure fields](/docs/entities/catalog-measures/fields)
- [Filtering syntax](/docs/filtering)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
