Core concepts

Pagination

List endpoints return one page at a time, newest first. Follow nextCursor until it's null.

Parameters#

Query parameterMeaning
limitItems per page, from 1 to 100. Default 25. Values outside the range are clamped to it.
cursorThe nextCursor from the previous page. Leave it out for the first page. It's opaque: don't build or change it.

Response#

Page
{
  "data": ["…"],
  "nextCursor": "aWQ6NTAxMg",
  "hasMore": true
}
  • Items are ordered newest first.
  • On the last page, nextCursor is null and hasMore is false.
  • Keep any filters the same on every page of one read.
  • Items created while you page don't appear on later pages, because they're newer than the cursor. Start again from the first page to pick them up.

Which endpoints are paginated#

Paginated (returns a page)Not paginated (returns an array)
GET /customers
GET /invoices
GET /webhook-endpoints/{id}/deliveries
GET /customers/{id}/enrollments
GET /invoices/{id}/payments
GET /webhook-endpoints

Reading every page#

let cursor = null;
do {
  const url = new URL(`${process.env.FLUX_BASE_URL}/api/v1/invoices`);
  url.searchParams.set("limit", "100");
  if (cursor) url.searchParams.set("cursor", cursor);
  const response = await fetch(url, { headers: { Authorization: `ApiKey ${process.env.FLUX_API_KEY}` } });
  const page = await response.json();
  for (const invoice of page.data) console.log(invoice.number, invoice.status);
  cursor = page.nextCursor;
} while (cursor);