ClocknextClocknextHelp
DocumentationAPI ReferenceMCP Tools
Dashboard

Get started

OverviewQuickstart

Good to know

Response formatHandling errorsPaginating resultsSending data reliablyYour own customer idsWebhooks

API reference

Signals

Record credit POSTRecord outcome POSTComplete outcome POSTRecord wallet POSTRecord unit POSTComplete composite POSTList raw signals GETRetry signals POSTList Customer Usage Log GETLook Up Usage Logs by ID GET

Deprecated

Record credit POSTRecord outcome POSTComplete outcome POSTRecord wallet POSTRecord unit POSTComplete composite POSTList raw signals GETRetry signals POST

Customers

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 for wallet PUTGet a customer's current plan GETChange a recurring grant PUTUpdate a customer's card POSTGet a customer's invoice balance GETAdjust a customer's invoice balance POST

Deprecated

List Customer Usage Log GETLook Up Usage Logs by ID GET

Manage

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

Members

List a customer's members GETAdd a member POSTUpdate a member PATCHRemove a member DELETE

Plans and Entitlements

PlansPackagesCreditsOutcomesUnitsComposites

Taxes

List taxes GETCreate a tax POSTGet a tax GETUpdate a tax PATCH

Purchases

List purchases GETCreate a purchase POSTGet a purchase GETUpdate a purchase's auto-payment setting PATCHCancel a purchase POST

Checkout

Create a checkout POST

Subscriptions

List subscriptions GETGet a subscription GETCancel a subscription POSTAdd packages to a subscription POSTRemove a package from a subscription POST

Plan changes

List plan changes GETPreview a plan change POSTChange a customer's plan POSTGet a plan change GET

Invoices

List invoices GETGet an invoice GETMint a hosted pay link GETRecord a payment POST

Credit notes

List credit notes GETCreate a credit note POSTGet a credit note GETVoid a credit note POST

Refunds

List refunds GETRefund to the card POSTGet a refund GET

Payments

List payments GETGet a payment GET

Webhooks

Customer Portal

Mint a customer-portal access token POST

Create a purchase

Subscribes a customer to a plan. It is PENDING with a first invoice (invoice.payUrl) and starts once that is paid. With autoPayment: true the balance, then the saved card, pay it. A FREE plan starts at once. It replaces any current plan without credit; for credit, change plan.

Base URL https://payments.clocknext.com/api/v1

POST
/purchases

Authorization

apiKey
headerAuthorizationBearer <cnk_…>

Organisation-scoped key from Settings → API Keys.

Request Body

application/json
  1. body
  1. body
  2. …

Name the customer with customerId or externalId — one is required.

customerId?string

Customer id. Required unless externalId is sent.

Length1 <= length
externalId?string

Your own id for the customer, instead of customerId.

Match^[A-Za-z0-9-]{1,64}$
Length1 <= length <= 64
planId*string

The id of the plan to subscribe the customer to. It must be active: an archived plan is a 400.

Length1 <= length
billingDate?string

YYYY-MM-DD: date of the first invoice. Defaults to today; can't be in the past.

Formatdate
subscriptionDate?string

YYYY-MM-DD: when the plan starts and renews. Defaults to today; can't be before this month.

Formatdate
notes?string

A free-text note stored on the purchase. Up to 500 characters, after leading and trailing spaces are removed.

Lengthlength <= 500
autoPayment?boolean

true: the balance, then the saved card, pay every invoice, the first one too. Default false.

Defaultfalse
voidAfterMinutes?integer

Minutes an unpaid renewal invoice stays open before it is voided.

Range1 <= value

Response Body

Purchase created.

application/json
  1. response
  1. response
  2. …
statusCode*integer

The HTTP status code of the response, repeated in the body.

statusDetail*

The status of the request. status is SUCCESS, and message says what happened.

result*

The new purchase and, when there is one, its first invoice to pay.

curl -X POST 'https://payments.clocknext.com/api/v1/purchases' \  -H 'Content-Type: application/json' \  -d '{  "customerId": "cmvgva5po000c07iir1vtn8vl",  "planId": "cmvgvg2yq000s08l21gkr472h",  "notes": "Annual kickoff — upgraded from Starter",  "autoPayment": false}'
Example Response
{  "statusCode": 201,  "statusDetail": {    "status": "SUCCESS",    "message": "Purchase created."  },  "result": {    "purchase": {      "id": "cmvgvkmxz002h08l2h2i1dnsr",      "purchaseNumber": "PUR-001",      "subscriptionNumber": "SUB-001",      "customerId": "cmvgva5po000c07iir1vtn8vl",      "customerName": "Northwind Traders",      "customerLogoUrl": "https://img.logo.dev/northwindtraders.com?token=pk_XyJ5Zd6NSUexPIq3rDQr4A&size=128&format=png&retina=true",      "planId": "cmvgvg2yq000s08l21gkr472h",      "planName": "Pro",      "planType": "BUNDLE",      "hasWallet": true,      "hasCredit": true,      "hasOutcome": true,      "hasUnit": true,      "hasComposite": true,      "billingCycle": "MONTHLY",      "cost": 499,      "currencyCode": "USD",      "billingDate": "2026-10-20T00:00:00.000Z",      "nextBillingDate": "2026-11-20T00:00:00.000Z",      "status": "PENDING",      "voidAfterMinutes": 52560000,      "autoPayment": false,      "autoPaymentPauseReason": null,      "notes": "Annual kickoff — upgraded from Starter",      "createdAt": "2026-10-20T16:05:52.295Z"    },    "invoice": {      "id": "cmvgvkn14002u08l2ct47s2a7",      "invoiceNumber": "INV-0001",      "amount": 535.18,      "status": "OPEN",      "payUrl": "https://payments.clocknext.com/pay/<token>.vIKjeEFzR0YC_z5epJPcxKjavvXrik32JXc9fNbzDxk"    }  }}

Types

Every object type on this page, with its fields.

CreatePurchaseInput

Name the customer with customerId or externalId — one is required.

FieldTypeRequiredDescription
customerIdstringnoCustomer id. Required unless externalId is sent.
externalIdExternalIdnoYour own id for the customer, instead of customerId.
planIdstringyesThe id of the plan to subscribe the customer to. It must be active: an archived plan is a 400.
billingDatestringnoYYYY-MM-DD: date of the first invoice. Defaults to today; can't be in the past.
subscriptionDatestringnoYYYY-MM-DD: when the plan starts and renews. Defaults to today; can't be before this month.
notesstringnoA free-text note stored on the purchase. Up to 500 characters, after leading and trailing spaces are removed.
autoPaymentbooleannotrue: the balance, then the saved card, pay every invoice, the first one too. Default false.
voidAfterMinutesintegernoMinutes an unpaid renewal invoice stays open before it is voided.

CreatePurchaseInput.externalId

The id YOUR product uses for a customer: 1–64 letters, numbers or "-", matched exactly (case-sensitive). Unique among the organisation's active customers — an archived customer's id can be reused.

Purchase

FieldTypeRequiredDescription
idstringyesThe purchase's id.
purchaseNumberstringyesThe workspace's reference for the purchase, such as PUR-042.
subscriptionNumberstring | nullyesThe subscription's reference. null on a FREE plan and on older purchases.
customerIdstringyesThe id of the customer who holds the purchase.
customerNamestringyesThe customer's name.
customerLogoUrlstring | nullyesThe customer's logo URL. It can be a data: URL. null when no logo is set.
planIdstring | nullyesThe id of the plan bought. null when that plan was deleted later.
planNamestringyesThe plan's name, saved when the purchase was created.
planType"WALLET" | "BUNDLE"yesBUNDLE when the plan has credit, outcome or composite lines, else WALLET. Saved at purchase.
hasWalletbooleanyesWhether the plan has a wallet line. Read from the plan as it is now. false when the plan was deleted.
hasCreditbooleanyesWhether the plan has a credit line. Read from the plan as it is now. false when the plan was deleted.
hasOutcomebooleanyesWhether the plan has an outcome line. Read from the plan as it is now. false when the plan was deleted.
hasUnitbooleanyesWhether the plan has a unit line. Read from the plan as it is now. false when the plan was deleted.
hasCompositebooleanyesWhether the plan has a composite line. Read from the plan as it is now. false when the plan was deleted.
billingCycle"MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "YEARLY" | "FREE"yesThe plan's billing cycle, saved when the purchase was created.
costnumberyesThe pay-in-advance price of one cycle in USD, saved at purchase. 0 on a FREE plan; usage is billed apart.
currencyCodestringyesThe currency the plan's price was set in, for display. cost stays in USD.
billingDatestringyesThe purchase's billing date, as set when it was created.
nextBillingDatestringyesWhen the next billing period starts. Before the plan starts, when its first period starts.
status"COMPLETED" | "PENDING" | "CANCELLED"yesCOMPLETED, PENDING or CANCELLED, by payment.
voidAfterMinutesintegeryesMinutes an unpaid renewal invoice stays open before it is voided.
autoPaymentbooleanyesWhen true, invoices from the second cycle on are charged to the saved card.
autoPaymentPauseReasonstring | nullyesThe pauseReason sent when auto-payment was paused. null while it is on.
notesstring | nullyesA free note saved on the purchase. null when none was given.
createdAtstringyesWhen the purchase was created.

PurchaseFirstInvoice

The first invoice to pay, with its payment link. Left out when there is none (a FREE or pay-as-you-go plan) or the invoice balance paid it all.

FieldTypeRequiredDescription
idstringyesThe id of the first invoice.
invoiceNumberstringyesThe workspace's reference for the first invoice, such as INV-0042.
amountnumberyesTotal due in USD, tax included. 0 on the $0 card invoice.
statusstringyesAlways OPEN: the invoice waits for payment.
payUrlstringnoThe hosted payment page. Left out while autoPayment is there.
autoPaymentobjectnoWith autoPayment: true and a saved card: the card is being charged. Left out otherwise.

PurchaseFirstInvoice.autoPayment

With autoPayment: true and a saved card: the card is being charged. Left out otherwise.

FieldTypeRequiredDescription
status"PROCESSING"yesPROCESSING: the saved card is being charged.
messagestringyesA short note for people: "The saved card is being charged."

List purchases GET

The workspace's purchases, newest first. Filter by `customerId` or `status` (`COMPLETED`, `PENDING` or `CANCELLED`). Paged with `limit` (at most 50) and `cursor`; see [Paginating results](/docs/api-reference/pagination). Any other parameter is a `400`.

Get a purchase GET

One purchase. `status` is by payment (`COMPLETED`, `PENDING` or `CANCELLED`); `lifecycleStatus` says whether the plan has started.