Pagination

Page through Kustomer list endpoints with page and pageSize, follow links.next, and handle cursor-based and very large result sets.

List endpoints return results a page at a time. Most use page numbers; a few use cursors. Either way, the safest approach is to follow links.next until it's null.

Page-number pagination

Pass page (starting at 1) and pageSize:

Shell
curl "https://acme.api.kustomerapp.com/v1/customers?page=2&pageSize=100" \
  -H "Authorization: Bearer $KUSTOMER_API_KEY"
200 OK
{
  "meta": { "pageSize": 100, "page": 2, "total": 4210, "totalPages": 43 },
  "links": {
    "self": "/v1/customers?page=2&pageSize=100",
    "first": "/v1/customers?page=1&pageSize=100",
    "prev": "/v1/customers?page=1&pageSize=100",
    "next": "/v1/customers?page=3&pageSize=100"
  },
  "data": [ ... ]
}
FieldMeaning
meta.page, meta.pageSizeThe page you got and its size
meta.total, meta.totalPagesTotal matches and pages, on endpoints that report them
links.nextPath to the next page, or null on the last page
links.prev, links.first, links.lastOther pages, where available
InteractiveFollowing links.next, page by page
pageSize
47 customers · nothing fetched yet
Select a page to request it with ?page=
Your code
Kustomer API
GET /v1/customers?page=1&pageSize=10
next: the first request
Response
No response yet. Send the first request, or press play.
Search stops at 10,000 matches
matches
pageSize

300 pages · only pages 1–100 (10,000 records) can be fetched; asking for page 101 returns 400. Split the query into at least 3 windows on updated_at and page through each.

A simulated 47-record list. In page-number mode, select any page to request it directly; prev is null on page 1 and next is null on the last page. The loop never builds URLs itself: it requests links.next until it is null.

Page sizes

pageSize limits vary by endpoint. The reference page for each list shows its default and maximum.

EndpointsTypical maximum
Most lists100
Users and teams500
Search500
Customer list (GET /v1/customers)1,000
Conversation times1,000

Request the largest page size you can handle. Fewer, larger pages use less of your rate limit.

Iterate every page

async function* listAll(path: string) {
  let next: string | null = `${path}${path.includes('?') ? '&' : '?'}pageSize=100`
  while (next) {
    const res = await kfetch(next) // retries 429s; see Making requests
    const body = await res.json()
    yield* body.data
    next = body.links?.next ?? null
  }
}

for await (const customer of listAll('/v1/customers')) {
  console.log(customer.id, customer.attributes.name)
}

links.next is a path. Prefix it with your base URL.

Cursor pagination

A few endpoints, such as the audit log, page with before and after cursors instead. Their links.next already contains the cursor:

JSON
{ "links": { "next": "/v1/audit-logs?count=1&before=62799c44a96e7f160834199c" } }

The same "follow links.next" loop works without changes.

Large result sets

Deep pagination gets slower and can hit limits. For exports and syncs:

  • Customer list and search return only the first 10,000 matches. GET /v1/customers, POST /v1/customers/search and POST /v1/customers/archive/search share a 10,000-match window. The last reachable page is floor(10,000 / pageSize), and never above 999. A higher page returns 400 with a badparam error on page. On the last reachable page, links.next is null and links.last points there; meta.totalPages can still be higher when more matches exist. When pageSize does not divide 10,000, or the 999-page cap binds first, matches inside the window can be left unread (for example pageSize=333 stops at page 30 / 9,990 matches, and pageSize=5 stops at page 999 / 4,995) — compare meta.totalPages with the pages you read. If pages remain unread and the query matches 10,000 or fewer, restart from page=1 with a pageSize that divides 10,000 (such as 100, 250 or 500). If the query matches more than 10,000, restarting only re-reads the same window — split into smaller windows instead. Do not continue at the next page number after changing pageSize — page offsets depend on pageSize, so that can duplicate or skip matches. Search pageSize goes up to 500 (a larger value is treated as 500); the customer list goes up to 1,000. Search also accepts pageSize=0 for counts only, which doesn't apply the window. Split large queries into time windows on updated_at or created_at, and page through each window. See Search recipes.
  • Sort for stability. Records created or updated while you page can shift between pages. Window by time, or sort by a stable field where the endpoint supports it. The customer list adds an id tie-break so equal sort values stay in a consistent order across pages.
  • Incremental sync. After the first full pass, query only records updated since your last run instead of re-listing everything.
  • Subscribe instead of polling. If you poll for changes, consider outbound webhooks.