# Pagination (/pagination)



Lists are cursor-paginated:

```json
{
  "data": [],
  "meta": { "has_more": true, "next_cursor": "1287" }
}
```

Pass `next_cursor` back as `starting_after` for the next page. Stop when
`has_more` is `false`.

```bash
curl "https://app.sendkuy.com/api/v1/contacts?limit=50&starting_after=1287" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"
```

`limit` defaults to 20 and is capped at 100.

## With an SDK [#with-an-sdk]

`autoPaginate()` walks every page for you, fetching the next one only when the
loop reaches it:

<CodeBlockTabs defaultValue="Node.js">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="Node.js">
      Node.js
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="PHP">
      PHP
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="Node.js">
    ```ts
    const page = await sendkuy.contacts.list({ limit: 100 });

    for await (const contact of page.autoPaginate()) {
      console.log(contact.id);
    }
    ```
  </CodeBlockTab>

  <CodeBlockTab value="PHP">
    ```php
    foreach ($sendkuy->contacts()->list(['limit' => 100])->autoPaginate() as $contact) {
        echo $contact->id;
    }
    ```
  </CodeBlockTab>
</CodeBlockTabs>

To go one page at a time, `nextPage()` returns the next page, or `null` after
the last. A PHP page can also be counted and looped over directly; that covers
the rows of that one page only.

## The cursor is opaque [#the-cursor-is-opaque]

Its shape differs between endpoints and can change without notice. Treat it as
a string you hand back, not as something to parse, compare or construct.

## Four endpoints answer without `meta` [#four-endpoints-answer-without-meta]

`POST /messages`, `POST /messages/batch`, `POST /whatsapp/numbers/check` and
`GET /contact-attributes` return `{ "data": [...] }` with **no `meta` at all**.
They are lists, not pages — nothing was cut off, so there is nothing to page
through. Three of them return one row per element you sent; the fourth returns
every attribute you have defined.

Code that assumes `meta` exists on every array response will break on exactly
those four.
