ClocknextHelp
DocumentationAPI ReferenceMCP Tools
Dashboard

Get started

OverviewQuickstart

Good to know

Response formatHandling errorsPaginating resultsSending data reliablyYour own customer idsWebhooks

API reference

Record credit POSTRecord outcome POSTComplete outcome POSTRecord wallet POSTRecord unit POSTComplete composite POST
List customers GETCreate a customer POSTGet a customer GETUpdate a customer PATCHDelete a customer DELETEGet a customer's balances GETGet a customer's wallet ledger GETSet a customer's low-balance alert PUTGet a customer's current plan GETChange a recurring grant PUTList Customer Usage Log GETLook Up Usage Logs by ID GET
Manage a customer's credit balance POSTManage a customer's outcome balance POSTManage a customer's unit balance POSTManage a customer's composite balance POSTManage a customer's wallet balance POST
List a customer's members GETAdd a member POSTUpdate a member PATCHRemove a member DELETE
PlansCreditsOutcomesUnitsComposites
List taxes GETCreate a tax POSTGet a tax GETUpdate a tax PATCH
List purchases GETCreate a purchase POSTGet a purchase GETUpdate a purchase's auto-payment setting PATCHCancel a purchase POST
List invoices GETGet an invoice GETMint a hosted pay link GET
List payments GETGet a payment GET
wallet.balance.update POSTwallet.balance.drop POST
Mint a customer-portal access token POST

API Reference

Paginating results

Page through list endpoints with limit and cursor.

List endpoints — such as GET /customers, GET /invoices, and GET /payments — 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, then pass the id of the last row you received as the cursor for the next request. When a page returns fewer rows than limit, you've reached the end.

# First page
curl "https://payments.clocknext.com/api/v1/customers?limit=50" \
  -H "Authorization: Bearer $CLOCKNEXT_API_KEY"

# Next page — cursor is the last id from the page above
curl "https://payments.clocknext.com/api/v1/customers?limit=50&cursor=cus_abc123" \
  -H "Authorization: Bearer $CLOCKNEXT_API_KEY"
// One page at a time
const page = await cnk.customers.list({ limit: 50, q: "ac" });

// Or let the SDK follow the cursor for you across every page
for await (const customer of cnk.customers.iterate()) {
  console.log(customer.id);
}

The @clocknext/sdk client exposes list() for a single page and iterate() (an async iterator) that walks the whole set, so you rarely touch the cursor by hand.

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 200; anything larger is clamped.

Handling errors

Every status code the API returns, what it means, and how to handle it.

Sending data reliably

How the SDK sends signals — buffered by default, with retries, idempotency, and the flush() you must call before a serverless function exits.

On this page

Query parametersPaging forward