Pagination

Pagination fields vary slightly by backing service. Use the query and response field names advertised by the specific endpoint rather than assuming every list uses the same mechanism.

Rules

  • Send query fields in snake_case.
  • Treat cursors and page tokens as opaque; do not parse or modify them.
  • Preserve the same filters and sort order while advancing through a result set.
  • Stop when the response has no continuation cursor/token or reports no next page.
  • Use bounded page sizes and back off after 429 responses.

Cursor pattern

let cursor

do {
  const url = new URL('/api/v1/management/clients', apiBase)
  url.searchParams.set('page_size', '50')
  if (cursor) url.searchParams.set('cursor', cursor)

  const page = await fetch(url, { headers }).then((response) => response.json())
  consume(page.items ?? page.data ?? [])
  cursor = page.next_cursor ?? page.next_page_token
} while (cursor)

Do not use a cursor from one user, client, environment, or filter set with another request.

Was this page helpful?