## Ratings (CSAT)

> ⚠️ **The method ships in update `imopenlines 26.700.0` and is not yet available on all Bitrix24 portals.** If the update has not reached your portal yet, the API returns `422 METHOD_NOT_YET_AVAILABLE` — this means the method has not been released on the portal yet, not that the integration is broken.

`POST /v1/openlines/ratings/search`

A list of sessions with a customer rating (like/dislike) for a period — for CSAT reports and feedback export. Sessions without a customer rating do not appear in the list.

## Request fields (body)

| Field | Type | Req. | Description |
|------|-----|:-----:|---------|
| `dateVoteFrom` | string | yes | Start of the rating period, ISO 8601. The `dateVoteFrom`..`dateVoteTo` period must not exceed 1 year |
| `dateVoteTo` | string | yes | End of the rating period, ISO 8601 |
| `configId` | number | no | Line identifier. Source: [`GET /v1/openline-configs`](/docs/openlines/config/list) |
| `configIdList` | number[] | no | List of lines |
| `operatorId` | number | no | Operator identifier. Source: [`GET /v1/users`](/docs/entities/users) |
| `operatorIdList` | number[] | no | List of operators |
| `source` | string | no | Channel code |
| `sourceList` | string[] | no | List of channel codes |
| `vote` | string | no | Customer rating: `like` / `dislike`. Without the parameter, all rated sessions are returned |
| `hasVoteHead` | boolean | no | Whether there is a supervisor rating. Accepts `true`/`false` and `Y`/`N` |
| `limit` | number | no | Page size, 1..200 (default 50) |
| `offset` | number | no | Pagination offset (default 0) |

The `dateVoteFrom`/`dateVoteTo` period is required — the bound protects against heavy queries over the session table. If the customer rating is disabled on a line, the method returns an empty list (no rated sessions appear on such a line).

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/openlines/ratings/search" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "configId": 3,
    "vote": "like",
    "dateVoteFrom": "2026-06-01T00:00:00+00:00",
    "dateVoteTo": "2026-06-30T23:59:59+00:00"
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/openlines/ratings/search" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "configId": 3,
    "vote": "like",
    "dateVoteFrom": "2026-06-01T00:00:00+00:00",
    "dateVoteTo": "2026-06-30T23:59:59+00:00"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/ratings/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    configId: 3,
    vote: 'like',
    dateVoteFrom: '2026-06-01T00:00:00+00:00',
    dateVoteTo: '2026-06-30T23:59:59+00:00',
  }),
})
const { data } = await res.json()
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/ratings/search', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    configId: 3,
    vote: 'like',
    dateVoteFrom: '2026-06-01T00:00:00+00:00',
    dateVoteTo: '2026-06-30T23:59:59+00:00',
  }),
})
const { data } = await res.json()
```

## Response fields

The response is `{ "success": true, "data": { "ratings": [...], "hasNextPage": bool } }`.

| Key | Description |
|---|---|
| `ratings[].sessionId` | Session identifier |
| `ratings[].configId` | Line identifier |
| `ratings[].operatorId` | Operator identifier |
| `ratings[].source` | Channel code |
| `ratings[].vote` | Customer rating (`like` / `dislike`) |
| `ratings[].voteHead` | Supervisor rating, a number 1..5 (`null` if no right) |
| `ratings[].commentHead` | Supervisor comment (`null` if no right) |
| `ratings[].dateVote` | Date the customer left the rating |
| `ratings[].dateSessionClose` | Session close date |
| `hasNextPage` | Whether there is a next page (a field of the `data` envelope, not of an element) |

## Response example

```json
{
  "success": true,
  "data": {
    "ratings": [
      {
        "sessionId": 1024,
        "configId": 3,
        "operatorId": 42,
        "source": "livechat",
        "vote": "like",
        "voteHead": 5,
        "commentHead": "Great work",
        "dateVote": "2026-06-15T14:53:00+00:00",
        "dateSessionClose": "2026-06-15T14:52:10+00:00"
      }
    ],
    "hasNextPage": false
  }
}
```

## Error response example

`400` — the rating period is missing:

```json
{
  "success": false,
  "error": { "code": "MISSING_PARAMS", "message": "Required: dateVoteFrom, dateVoteTo (ISO 8601 strings)" }
}
```

## Errors

| HTTP | Code | When |
|---|---|---|
| 403 | `B24_TARIFF_RESTRICTION` | The tariff does not include Open Channels statistics (`report_open_lines`) |
| 400 | `MISSING_PARAMS` | The required `dateVoteFrom`/`dateVoteTo` are missing |
| 422 | `BITRIX_ERROR` (`error.b24Code: INVALID_FILTER`) | An invalid `vote` value or date format |
| 422 | `BITRIX_ERROR` (`error.b24Code: PERIOD_TOO_LARGE`) | The period exceeds 1 year |
| 422 | `BITRIX_ERROR` (`error.b24Code: OFFSET_TOO_LARGE`) | `offset` exceeds the maximum — narrow the period |
| 422 | `METHOD_NOT_YET_AVAILABLE` | The `imopenlines 26.700.0` update has not reached the portal yet |

## Pagination without page drift

The method is paged with `offset`/`limit`. For a paged export, fix the upper bound of the period — set `dateVoteTo` to the moment the export starts so that new ratings do not shift the pages.

The full list of system codes — [API errors](/docs/errors).

## See also

- [Session list](/docs/openlines/sessions)
- [Per-line aggregates for a period](/docs/openlines/stats)
- [Open Channels statistics](/docs/openlines)
