
## Template search

`POST /v1/bizproc-templates/search`

Selects business process templates that match the specified conditions and returns them as a list. The difference from the template list is that the selection conditions are passed in the request body, so a complex filter does not have to fit into the query string.

## Request fields (body)

| Field | Type | Default | Description |
|------|-----|-----------|---------|
| `filter` | object | — | Filtering by the fields of [`GET /v1/bizproc-templates/fields`](./fields.md).<br>[Filtering syntax](/docs/filtering). Example: `{ "entity": "CCrmDocumentLead" }`.<br>The values of `moduleId` and `entity` are the first two elements of `documentType`, listed in [Upload a template](./create.md) |
| `select` | string[] | — | Fields in the response: `id`, `moduleId`, `entity`, `documentType`, `autoExecute`, `name`, `description`, `modified`, `isModified`, `userId`. Without `select`, the full declared field set is returned |
| `order` | object | — | Sorting. Example: `{ "id": "desc" }` |
| `limit` | number | `50` | Number of records in the response, up to 5000. Zero does not mean "no limit" — it is ignored, 50 records arrive together with the `LIMIT_ZERO_IGNORED` warning |
| `offset` | number | `0` | Offset from the start of the selection |
| `autoWindow` | boolean | `true` | Split the selection into weekly windows when the filter covers a `modified` range wider than 14 days. `false` disables the split |

## Examples

Templates can be searched only with an authorization key — both examples send the authorization key and the `Authorization: Bearer` header. The session token is issued by OAuth authorization, is valid for 24 hours, and cannot be renewed — [Passing the key](/docs/keys-auth#passing-the-key).

### curl — authorization key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/bizproc-templates/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": { "moduleId": "crm" },
    "select": ["id", "name", "entity", "autoExecute"],
    "order": { "id": "desc" },
    "limit": 3
  }'
```

### JavaScript — authorization key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bizproc-templates/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filter: { moduleId: 'crm' },
    select: ['id', 'name', 'entity', 'autoExecute'],
    order: { id: 'desc' },
    limit: 3,
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of templates. The fields of each element are defined by `select`, the full schema is in [Template fields](./fields.md). The `templateData` template file is not returned in responses |
| `meta.total` | number | Number of templates matching the filter |
| `meta.hasMore` | boolean | Whether there are records beyond `limit` |
| `meta.durationMs` | number | Request duration in milliseconds |
| `meta.warnings` | array | Warnings about how the request was parsed. Each one is an object with the `code`, `field`, and `message` fields, for example an unknown field name in `select` with the `UNKNOWN_SELECT_FIELD` code |
| `meta.autoWindowed` | boolean | `true` if the selection was split into time windows |
| `meta.windowCount` | number | Number of windows the date range was split into. Arrives when `autoWindowed` is `true` |
| `meta.batchWaves` | number | Number of parallel request waves used when splitting into windows |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": 1237,
      "name": "Contract approval",
      "entity": "CCrmDocumentDeal",
      "autoExecute": 1
    },
    {
      "id": 1153,
      "name": "Purchase request",
      "entity": "CCrmDocumentDeal",
      "autoExecute": 0
    },
    {
      "id": 1143,
      "name": "Inquiry processing",
      "entity": "CCrmDocumentLead",
      "autoExecute": 0
    }
  ],
  "meta": {
    "total": 18,
    "hasMore": true,
    "durationMs": 113
  }
}
```

## Error response example

403 — the request was sent with an API key:

```json
{
  "success": false,
  "error": {
    "code": "OAUTH_REQUIRED",
    "message": "bizproc-templates require an OAuth app key (vibe_app_*) with an Authorization: Bearer session — a personal vibe_api_* key lacks the per-user OAuth context Bitrix24 needs for these methods. Create an OAuth app (POST /v1/apps) and retry with its key. On this 403 switch keys — do NOT delete or recreate the app (that discards anything already registered under it, e.g. a bizproc robot you just registered)."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_FILTER_OPERATOR` | An unknown operator in the filter. The message lists the supported operators |
| 400 | `INVALID_FILTER_OPERATOR` | A logical key `$or` or `$and` in the filter. An OR condition is expressed with the `$in` operator for one field or with parallel requests through [`POST /v1/batch`](/docs/batch), an AND condition with sibling keys of one filter |
| 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. Take 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 |
| 403 | `OAUTH_REQUIRED` | The request was sent with an API key. Templates can be searched only with an authorization key |
| 401 | `TOKEN_MISSING` | Authorization key without the `Authorization: Bearer` header |
| 401 | `WRONG_AUTH_SCHEME` | The authorization key was sent in the `Authorization: Bearer` header. The key goes in `X-Api-Key`, while `Authorization: Bearer` carries the session token |
| 401 | `INVALID_SESSION` | The session token has expired or is invalid — authorize again |
| 403 | `SCOPE_DENIED` | The key lacks the `bizproc` scope |

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

## Known specifics

**The identifier must be listed in `select` explicitly.** `id` is not added to the selected fields — if it is needed for a later update or delete, include it in `select` yourself.

**When the selection is split into windows, `meta.total` counts only the windows that were read.** A `modified` range filter wider than 14 days reads the selection in weekly windows and stops once it has collected `limit` records: `meta.total` then carries the count from the windows already read, which is lower than the full count. The exact count comes from a request with `autoWindow: false` or from reading the whole selection in one request with `limit` up to 5000.

**An unknown field name does not interrupt the request.** In `filter` the result set is not narrowed, in `order` the sort order does not change, in `select` the field is absent from the records, and a warning with the `UNKNOWN_SELECT_FIELD` code arrives in `meta.warnings`. Check field names against the schema at [`GET /v1/bizproc-templates/fields`](./fields.md).

## See also

- [Template list](/docs/entities/bizproc-templates/list)
- [Template fields](/docs/entities/bizproc-templates/fields)
- [Upload a template](/docs/entities/bizproc-templates/create)
- [Filtering syntax](/docs/filtering)
- [Keys and authorization](/docs/keys-auth)
