> For the complete documentation index, see [llms.txt](https://detected.gitbook.io/detected-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://detected.gitbook.io/detected-api-docs/rest-apis/pagination.md).

# Pagination

Endpoints that return a list of items, such as alerts, profiles or documents, return the results in pages. These endpoints accept a `page` query parameter.

The number of items per page is set by the API and returned in `meta.per_page`.

### Requesting a page

Use the `page` query parameter to choose which page to return. Pages start from 1, and the first page is returned if `page` isn't set.

```bash
curl "https://api.detected.app/api/v2/public/alerts?page=2" \
  -H "Authorization: Bearer <access_token>"
```

### Paginated responses

Each response contains the items for the requested page in `data`, and two objects describing the pages:

```json
{
  "data": [ ... ],
  "links": {
    "first": "https://api.detected.app/api/v2/public/alerts?page=1",
    "last": "https://api.detected.app/api/v2/public/alerts?page=10",
    "prev": "https://api.detected.app/api/v2/public/alerts?page=1",
    "next": "https://api.detected.app/api/v2/public/alerts?page=3"
  },
  "meta": {
    "current_page": 2,
    "last_page": 10,
    "per_page": 30,
    "from": 31,
    "to": 60,
    "total": 274,
    "path": "https://api.detected.app/api/v2/public/alerts",
    "links": [ ... ]
  }
}
```

**links**: URLs of the first, last, previous and next pages. `prev` is `null` on the first page and `next` is `null` on the last page.

**meta.current\_page** / **meta.last\_page**: the number of the page returned, and of the last page.

**meta.per\_page**: the number of items per page.

**meta.from** / **meta.to**: the position of the first and last item on this page, counted across all pages, or `null` if there are no results.

**meta.total**: the total number of items across all pages.

**meta.path**: the endpoint URL without query parameters.

**meta.links**: a list of links for building page navigation, each with a `url`, a display `label`, the `page` number and whether it's the `active` page. For the previous and next links, `url` and `page` are `null` when there is no such page.

### Fetching all pages

To fetch every result, start with page 1 and follow `links.next` until it is `null`. Any filter parameters in your request are included in the `links` URLs.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://detected.gitbook.io/detected-api-docs/rest-apis/pagination.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
