# Pagination

Several List endpoints in the NVIDIA Run:ai control plane API return large collections. To retrieve results in smaller chunks, use offset/limit pagination.

## How Pagination Works

### Request Parameters

When an endpoint supports pagination, it typically exposes:

* `limit` - Maximum number of items to return (default 50, range 1..500)
* `offset` - The offset of the first item returned in the collection

Example (workloads): `GET /api/v1/authorization/access-rules?offset=0&limit=50`&#x20;

### Pagination Response

List responses may include a `next` field, alongside the collection itself (for example, `workloads`).&#x20;

Example response shape (workloads):

```json
{
  "next": 1,
  "roles": [ ... ]
}
```

Use `next` as the pointer for retrieving the next “page” of results. If `next` is not returned (or is empty), you’ve reached the end of the collection.

### Example: Paginate Through Workloads

#### Fetch the first page

```bash
curl -sS \
  -H "Authorization: Bearer <TOKEN>" \
  "https://console.<DOMAIN>/api/v2/authorization/roles?offset=0&limit=50"
```

The endpoint supports `offset` and `limit`.

#### Fetch the next page

Take the `next` value from the response and use it in the next request (as the next offset/page pointer).&#x20;

### Combine Pagination with Sorting and Filtering

The workloads list endpoint also supports:

* **Sorting** - `sortBy` and `sortOrder`&#x20;
* **Structured filtering** - `filterBy` with operators like `==`, `!=`, `>=`, `=@` (contains), etc.
* **Free-text search** - `search`&#x20;

Example:

```bash
curl -sS \
  -H "Authorization: Bearer <TOKEN>" \
  "https://console.<DOMAIN>/api/v2/authorization/roles?limit=100&offset=0&sortBy=createdAt&sortOrder=desc&filterBy=allocatedGPU>=2"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://run-ai-docs.nvidia.com/multi-tenant-api/2.22/getting-started/using-the-rest-api/pagination.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
