# Pagination

All endpoints that retrieve a collection of objects support cursor-based pagination. When you make a request to one of these endpoints, it will respond with the first page of objects in the collection. If the collection includes additional objects, the response will also include a `next_page` property that can be used to request the next page of objects.

<details>

<summary>Example pagination requests and responses</summary>

#### Requesting the first page

{% code title="GET /2023-04-11/customers" %}

```bash
curl -G $PLIRO_API_BASE_URL/2023-04-11/customers \
  -u "$PLIRO_API_KEY:" \
  -d limit=2
```

{% endcode %}

{% code title="Response" %}

```json
{
  "objects": [
    {
      "id": "cus_1BxEmDZEfaMhFQxkysiGtm",
      "email": "jane@example.com",
      "name": "Jane Doe",
      "newsletter_slugs": [],
      "plan_slug": null
    },
    {
      "id": "cus_1BxEm4QKh4Rb5v6Qvu2THx",
      "email": "john@example.com",
      "name": "John Doe",
      "newsletter_slugs": [],
      "plan_slug": null
    }
  ],
  "next_page": "Y3VzXzFCeEVtM1I1bjRQU1lVN3ZwZWFpY3E"
}
```

{% endcode %}

#### Requesting the second page

{% code title="GET /2023-04-11/customers" %}

```bash
curl -G $PLIRO_API_BASE_URL/2023-04-11/customers \
  -u "$PLIRO_API_KEY:" \
  -d page=Y3VzXzFCeEVtM1I1bjRQU1lVN3ZwZWFpY3E \
  -d limit=2
```

{% endcode %}

{% code title="Response" %}

```json
{
  "objects": [
    {
      "id": "cus_1BxEm3R5n4PSYU7vpeaicq",
      "email": "richard@example.com",
      "name": "Richard Roe",
      "newsletter_slugs": [],
      "plan_slug": null
    }
  ],
  "next_page": null
}
```

{% endcode %}

</details>

## Pagination parameters

`limit` **integer**\
The maximum number of objects to retrieve.

`page`  **string**\
Omit this parameter to request the first page. Provide the `next_page` value returned in a previous response to request the next page.

## The page object

```json
{
  "objects": [
    {
      "id": "cus_1BxEmDZEfaMhFQxkysiGtm",
      "email": "jane@example.com",
      "name": "Jane Doe",
      "newsletter_slugs": [],
      "plan_slug": null,
      "activation_url": null
    },
    {
      "id": "cus_1BxEm4QKh4Rb5v6Qvu2THx",
      "email": "john@example.com",
      "name": "John Doe",
      "newsletter_slugs": [],
      "plan_slug": null,
      "activation_url": null
    }
  ],
  "next_page": "Y3VzXzFCeEVtM1I1bjRQU1lVN3ZwZWFpY3E"
}
```

### Properties

`objects` **array**\
An array of objects in reverse chronological order.

`next_page` **optional string**\
A cursor for the next page of objects.
