## Search order properties

`POST /v1/order-properties/search`

Searches order property definitions using filter and sort conditions sent in the JSON request body.

## Request body fields

| Field | Type | Default | Description |
|----------|-----|-----------|---------|
| `filter` | object | — | Filter by fields from [`GET /v1/order-properties/fields`](/docs/entities/order-properties/fields).<br>[Filtering syntax](/docs/filtering). Example: `{ "id": 125, "type": "STRING" }` |
| `select` | string[] \| string | — | An array of fields, for example `["id", "name", "type"]`, or a comma-separated string. Only selected fields remain in `data`. Unknown names are reported in `meta.warnings` with the code `UNKNOWN_SELECT_FIELD` |
| `sort` | string \| object \| string[] | — | Sort as `"id"`, `"-sort,id"`, `{ "id": "desc" }`, or `["id", "-sort"]` |
| `order` | object | — | Sort using an object: `{ "id": "desc" }`. If `sort` is also set, it takes precedence |
| `limit` | number | `50` | Number of records, from 1 to 5000. Values above 5000 are capped at 5000 |
| `offset` | number | `0` | Number of records to skip |
| `withTotal` | boolean | — | Accepts `true` or `false`, but does not change counting or the presence of `meta.total` for order properties |

**Pagination.** When `limit > 50`, Vibecode automatically reads multiple pages of 50 records and combines them into one response. To fetch the next set, increase `offset` by the number of records received. Continue while `meta.hasMore` is `true`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/order-properties/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filter":{"id":125,"type":"STRING"},"select":["id","name","personTypeId","propsGroupId","type","active"],"limit":10,"offset":0,"withTotal":true}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/order-properties/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"filter":{"id":125,"type":"STRING"},"select":["id","name","personTypeId","propsGroupId","type","active"],"limit":10,"offset":0,"withTotal":true}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/order-properties/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { id: 125, type: 'STRING' },
    select: ['id', 'name', 'personTypeId', 'propsGroupId', 'type', 'active'],
    limit: 10,
    offset: 0,
    withTotal: true,
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/order-properties/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { id: 125, type: 'STRING' },
    select: ['id', 'name', 'personTypeId', 'propsGroupId', 'type', 'active'],
    limit: 10,
    offset: 0,
    withTotal: true,
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of order property definitions. All fields: [Order property fields](/docs/entities/order-properties/fields) |
| `meta.total` | number | Total properties matching the filter. Omitted on an empty page when `offset > 0` |
| `meta.hasMore` | boolean | Whether more records exist beyond the current page |
| `meta.durationMs` | number | Request duration in milliseconds |
| `meta.warnings` | array | Parameter warnings with `code`, `message`, and `field`. Included only when warnings exist |
| `meta.pageErrorSample` | object | Code and message of an error that interrupted automatic pagination. `data` then contains the records read before the interruption |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": 125,
      "name": "Comment for the courier",
      "personTypeId": 5,
      "propsGroupId": 9,
      "type": "STRING",
      "active": false
    }
  ],
  "meta": {
    "total": 1,
    "hasMore": false,
    "durationMs": 64
  }
}
```

## Error response example

400 — filtering by an unknown field:

```json
{
  "success": false,
  "error": {
    "code": "UNKNOWN_FILTER_FIELD",
    "message": "Unknown filter field 'unknownField' for entity 'order-properties'. Available: id, personTypeId, type, name, propsGroupId, code, sort, defaultValue, description, settings, xmlId, inputFieldLocation, active, required, multiple, userProps, util, isAddress, isAddressFrom, isAddressTo, isEmail, isFiltered, isLocation, isLocation4tax, isPayer, isPhone, isProfileName, isZip"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `UNKNOWN_FILTER_FIELD` | A filter field is not in the schema. Fields: [`GET /v1/order-properties/fields`](/docs/entities/order-properties/fields) |
| 400 | `INVALID_FILTER_FIELD` | A filter field name starts with the unsupported prefix `@` or `!@` |
| 400 | `INVALID_FILTER_OPERATOR` | An unknown operator, an empty condition object, or a logical `$or` or `$and` condition |
| 400 | `INVALID_DUPLICATE_FILTER_FIELD` | Two conditions resolve to the same filter condition. Send one of them |
| 400 | `INVALID_SORT_FIELD` | Sorting contains the forbidden name `__proto__`, `constructor`, or `prototype` |
| 400 | `UNKNOWN_SORT_FIELD` | Sorting by an unknown field |
| 400 | `INVALID_SORT_DIRECTION` | The sort direction specified in an object is not one of `asc`, `desc`, `ASC`, `DESC`, `1`, `-1` |
| 400 | `INVALID_FILTER_SHAPE` | `filter` is not an object of filter conditions |
| 400 | `INVALID_SORT_TYPE` | Sorting has an unsupported type |
| 400 | `INVALID_LIMIT` | `limit` is not a number or a numeric string |
| 400 | `INVALID_SELECT_TYPE` | `select` is not a string or an array of strings |
| 400 | `INVALID_REQUEST` | The request body is not a JSON object |
| 422 | `BITRIX_ERROR` | The key's user does not have permission in Bitrix24. The Bitrix24 code is in `error.b24Code`: `200040300010` |
| 403 | `BITRIX_ACCESS_DENIED` | The portal credentials do not have the `sale` scope (`insufficient_scope`) |
| 422 | `BITRIX_ERROR` | Bitrix24 rejects the request. The reason is in `error.message` |
| 403 | `SCOPE_DENIED` | The API key does not have the `sale` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | No Bitrix24 access tokens are configured |
| 429 | `RATE_LIMITED` | The request rate limit was exceeded. The effective limit is in the `x-ratelimit-limit` header. Retry after the interval in the `Retry-After` header |

Full list of common API errors: [Error codes](/docs/errors).

## See also

- [List order properties](/docs/entities/order-properties/list)
- [Get an order property](/docs/entities/order-properties/get)
- [Aggregate order properties](/docs/entities/order-properties/aggregate)
- [Order property fields](/docs/entities/order-properties/fields)
- [Order properties](/docs/entities/order-properties)
- [Filtering syntax](/docs/filtering)
- [Limits and optimization](/docs/optimization)
