API Reference
Paginating results
Page through list endpoints with limit and cursor.
List endpoints — GET /customers,
GET /invoices,
GET /payments,
GET /purchases and
GET /subscriptions — return one page at a time and page
forward with a cursor. Cursor paging is stable while rows are being inserted:
you never skip or repeat a record the way offset paging can.
Query parameters
Prop
Type
Some list endpoints add their own filters on top — for example customers
accepts q (a case-insensitive match on name or email), and catalogue endpoints
accept active=true to return only active records. See each endpoint's page for
the full parameter list.
Paging forward
Request the first page. Every answer has a nextCursor: the id of the last row
on the page. Pass it as the cursor of the next request. When nextCursor is
null, you have reached the last page.
A cursor that is not a row of your workspace (a typo, or the id of another
kind of record) is a 400 with the message Invalid `cursor`.. It never
looks like an empty last page. A row that changed after you read its page (an
invoice paid while you page through ?status=OPEN) is still a good cursor:
the next page starts right after it.
GET /subscriptions pages by purchase: limit counts purchases, and
nextCursor is the purchaseId of the last purchase on the page. A purchase's
period rows are never split across two pages, so a page can have more rows
than limit.
# First page
curl "https://payments.clocknext.com/api/v1/customers?limit=50" \
-H "Authorization: Bearer $CLOCKNEXT_API_KEY"
# Next page — cursor is result.nextCursor from the page above
curl "https://payments.clocknext.com/api/v1/customers?limit=50&cursor=cus_abc123" \
-H "Authorization: Bearer $CLOCKNEXT_API_KEY"
# Invoices, payments, purchases and subscriptions page the same way
curl "https://payments.clocknext.com/api/v1/invoices?limit=50&cursor=inv_abc123" \
-H "Authorization: Bearer $CLOCKNEXT_API_KEY"Unknown parameters
On invoices, payments, purchases and subscriptions, a query parameter the list
does not know is a 400, for example Unknown parameter `offset`. There is
no offset, page, after or startingAfter: page with cursor only.
Keep limit modest (the default of 50 is a good start) and let the cursor walk
the full set, rather than requesting a huge page. The maximum is 50 on the
billing lists and 200 on customers; anything larger is cut to the maximum.