# Pagination and filters

## Pages

Every list answers:

```json
{ "data": [ ... ], "hasMore": true, "nextCursor": "..." }
```

- Pass `nextCursor` back as `cursor` to get the next page. `nextCursor` is `null` on the last page; an unpaged list answers `hasMore: false, nextCursor: null`.
- The cursor is opaque. Never parse or build one.
- A cursor belongs to the request that issued it: the same operation, path and query parameters, except `cursor`, `limit`, `include` and `fields`, which may change between pages. Reused with other filters, order or search it answers `400 invalid_cursor`; drop `cursor` to start again.

## What a bare call returns

A list called with no `limit`, `cursor`, `filter` or `sort`:

| Kind of list | Returns |
|---|---|
| Paged (takes `limit`) | The first page, newest first by its time field. `limit` defaults to 25 unless the operation says otherwise; its maximum is in the operation's schema (100 for most; 50 for posts, mentions and memory facts; 500 for knowledge review pages and FAQs). |
| Unpaged (no `limit`) | Every row, in one answer, with `hasMore: false`. These are small by nature: connections, webhooks, templates, folders, collections, macros. |
| Messages in a conversation | Newest first; `sort=createdAt:asc` reads from the oldest, `filter=id:gt:<messageId>` only what came after that message. |

Narrow with `filter` instead of paging through everything. A list's lookback is a filter on its time field, with no hidden default window.

## Filters

```
GET /api/v1/inbox/conversations?filter=status:eq:open&filter=createdAt:gte:2026-10-01T00:00:00Z
```

- `filter=<field>:<operator>:<value>`, repeatable; repeated filters combine with AND.
- Each list names its own fields and operators in the OpenAPI document (`x-otobiz-filters`, also returned by the docs MCP server's `get_operation`). Anything else answers `400 invalid_filter`.
- `in` takes a comma list (any of, up to 20; `id:in` up to 100 ids, a batch read). A key-value field takes `<key>:<value>`, for example `attribute:eq:city:Pune`.
- A list's lookback is a filter on its time field (`createdAt:gte:<ISO time>`).
- `q` is free-text search where a list offers it.

## Order

```
GET /api/v1/inbox/reviews?sort=rating:asc
```

- `sort=<field>:<asc|desc>`, one value, from the list's `sort` parameter in the OpenAPI document; omitted = its first value.
- Rows that tie on the field keep one fixed order, so pages never skip or repeat a row.

## Rules every request follows

- Unknown query parameters and body fields answer `400 unknown_parameter`. They are never ignored.
- A field you omit in an update is kept; a field you send replaces its value; `null` clears it.
- `null` means unknown or not evaluated, never zero or false.
- A time WITH an offset is that exact instant. One without an offset is read in the default location's time zone (UTC when none is set); an item's own times read its location's zone (`locationId`, GET /api/v1/locations). Every time we return is UTC ISO-8601.
- `locationId` (a location) is a query parameter wherever an operation can be narrowed to one location. A key or sign-in limited to some locations sees only those; an id outside them answers `404`.

## How it behaves

- Rows added or removed while you page can shift what a later page holds.
- `hasMore: false` and `nextCursor: null` mean you have every row the list could read for the filter (check `meta` where a list has it).
- A list read from several connected channels answers what it could. `meta` says how many channels were asked and how many failed, with each failed one's `connectionId`, error and `retryAfter`.

## If it fails

| Answer | Cause | Fix |
|---|---|---|
| `400 invalid_cursor` | The cursor came from another list, or from the same list with different filters, order or search | Drop `cursor` and start again, or pass the exact query that returned it. |
| `400 invalid_filter` | A field or operator the list does not offer, or a value of the wrong type | Read the list's filters in the API reference, or with `get_operation` on the docs server, and use one of them. |
| `400 unknown_parameter` | A query parameter or body field the route does not accept | Remove or rename the field named in `param`. |
| `meta.connectionsFailed` above 0 | One connected channel could not answer, so its rows are missing | Retry after its `retryAfter` seconds. Do not treat the list as complete until it is 0. |
