Skip to navigation

Pagination

Every list endpoint can be walked two ways. To read a whole list (syncing customers, reconciling movements) use the cursor: objects created while you walk never shift the pages, so you never skip or repeat one. Paging by page keeps working as it always has.

By cursor

ParameterDefaultDescription
limit10How many objects to return, 1 to 100
starting_afterThe id of the last object you received. Returns the ones after it (older)
ending_beforeThe id of the first object you received. Returns the previous page (newer)

The list is always newest first by creation date, ending_before included. Send only one of starting_after or ending_before, and don’t combine them with page. Each endpoint’s filters (from_time, status, types[]…) still apply. If an object stops matching the filter while you walk (you archived it, its status changed), its id still works as a cursor.

On /payment_methods, /customers/{customer_id}/payment_methods, /product_variants, /inventory and the inventory movements, limit was already the page size, so limit alone keeps paging by page; there the cursor starts with starting_after, ending_before or X-List-Format: envelope. /inventory by cursor goes newest first, not lowest count first, because counts change with every sale and would shift the pages.

curl "https://app.recurrente.com/api/customers?limit=3" \
-H "X-SECRET-KEY: ..."

Response headers:

has-more: true
link: <https://app.recurrente.com/api/customers?limit=3&starting_after=cus_c3>; rel="next"

To move forward toward older objects, send the last object’s id as starting_after, or follow the link with rel="next". To move backward toward newer objects, send the first object’s id as ending_before, or follow the link with rel="prev". Each page is still ordered newest first.

has-more tells you whether objects remain in the direction you are walking: older when moving forward, newer when moving backward. When it is false, you are done in that direction. When moving backward, rel="next" can still exist even when has-more is false: that link returns toward older objects. The list object’s has_more field has the same meaning.

The list object

By default the body is the same as always: an array of objects (on /customers, inside customers). Send the X-List-Format: envelope header and the body is a list object, the same on every endpoint:

curl "https://app.recurrente.com/api/customers?limit=3" \
-H "X-SECRET-KEY: ..." \
-H "X-List-Format: envelope"
{
"object": "list",
"data": [{ "id": "cus_c1" }, { "id": "cus_c2" }, { "id": "cus_c3" }],
"has_more": true,
"url": "/api/customers"
}

With X-List-Format: envelope and no page, the list is walked by cursor even without limit.

Walking a whole list

async function* all(path) {
let startingAfter
do {
const query = new URLSearchParams({ limit: "100", ...(startingAfter && { starting_after: startingAfter }) })
const response = await fetch(`https://app.recurrente.com/api${path}?${query}`, {
headers: { "X-SECRET-KEY": process.env.RECURRENTE_SECRET_KEY, "X-List-Format": "envelope" },
})
const list = await response.json()
if (!response.ok) throw new Error(list.message)
yield* list.data
startingAfter = list.has_more ? list.data.at(-1).id : null
} while (startingAfter)
}
for await (const customer of all("/customers")) {
console.log(customer.id)
}

From the terminal, the CLI does the same with --all, 100 at a time (or the --limit you send), and walks backward if you start with --ending-before. It stops at 10,000 objects; if it answers has_more: true, resume with --starting-after and the last object’s id, or, if you were walking backward, with --ending-before and the first one’s:

recurrente customers list --all
recurrente customers list --all --ending-before cus_c3

Errors

All answer 400 with a code and the param that caused it:

codeWhen
invalid_limitlimit is not an integer from 1 to 100
pagination_conflictYou sent more than one of page, starting_after and ending_before
invalid_cursorThe id is not from this list: another account’s, the other environment’s, an object you deleted or, on some lists, outside the date filters you sent. If you deleted it, resume from the previous id you received
invalid_list_formatX-List-Format is neither array nor envelope

By page

ParameterDefaultDescription
page1Page number
items or limit10Items per page; outside 1 to 100 it is clamped without an error

By page, each list keeps its own order and the response carries these headers (RFC 8288):

HeaderDescription
linkNavigation links (first, prev, next, last)
current-pageCurrent page number
page-itemsItems per page
total-pagesTotal number of pages
total-countTotal number of records
has-moretrue if there is a next page

/webhook_endpoints, a subscription’s scheduled charges (/subscriptions/{id}/invoice_items), /lodging/connections and /lodging/rates answer the whole list when you send no cursor, as always; they don’t take page.

Not every listing is a list of objects: /banks, /sales_channels, the availability searches and /balances answer in full and take no cursor.

Before, limit without page had no effect on most lists. Now it walks by cursor: newest first and without total-count. If you want the list’s own order and the totals, send page.

If objects are created or deleted while you move between pages, the pages shift and you can see an object twice or miss it. To walk a whole list, use the cursor.