> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tesouro.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination, sorting, and filtering

> Learn how to paginate, sort, and filter results in the Embedded Banking API.

Tesouro REST APIs use cursor-based (keyset) pagination for list endpoints. This approach provides consistent performance regardless of dataset size and eliminates skipped or duplicated rows between pages.

## Pagination

### Request parameters

| Parameter          | Type    | Default | Description                                                                                                                          |
| ------------------ | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `limit`            | integer | 25      | Number of records to return per page. Maximum 100.                                                                                   |
| `pagination_token` | string  | null    | Opaque token from a previous response. When present, use the token exactly as returned — do not combine it with a different `limit`. |

### Response shape

Every paginated response returns the same structure:

```json lines theme={null}
{
  "data": [ ... ],
  "nextPaginationToken": "eyJ...",
  "prevPaginationToken": "eyJ..."
}
```

| Field                 | Description                                                                    |
| --------------------- | ------------------------------------------------------------------------------ |
| `data`                | Array of items for the current page.                                           |
| `nextPaginationToken` | Pass as `pagination_token` to get the next page. `null` on the last page.      |
| `prevPaginationToken` | Pass as `pagination_token` to get the previous page. `null` on the first page. |

<Info>
  Pagination tokens are **opaque**. Never parse, construct, or modify them — only round-trip them from responses back into requests.
</Info>

### Paginating through results

1. Make an initial request with `limit`:

   ```lines theme={null}
   GET /items?limit=25
   ```

2. Use `nextPaginationToken` from the response for the next page:

   ```lines theme={null}
   GET /items?pagination_token=eyJ...
   ```

3. Continue until `nextPaginationToken` is `null`.

## Sorting

The Embedded Banking API does **not** define global `sort` or `order` query parameters for list endpoints.

Sorting behavior is **endpoint-specific**:

* Some endpoints may document their own sorting parameters or fixed sort order in their reference pages.
* If an endpoint does not document sorting parameters, results are returned in that endpoint's default order and cannot be re-ordered via query parameters.

Always refer to the individual endpoint documentation to see whether sorting is supported and, if so, which query parameters and fields are available.

## Filtering

The Embedded Banking API uses **endpoint-specific filter parameters** rather than a generic filter syntax. Each list endpoint defines its own supported query parameters for narrowing results.

For example, a list endpoint might support:

```lines theme={null}
GET /items?organizationId=YOUR_ORG_ID&limit=25
```

<Info>
  Refer to the individual endpoint reference to see the exact filter parameters available for each resource.
</Info>
