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
Signals

Record unit

Records quantity (default 1) discrete units against agentKey.

POST
/signal/unit

Authorization

apiKey
AuthorizationBearer <token>

Organisation-scoped key from Settings → API Keys.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

No usage block — a unit carries no model and no tokens. One call is one report covering quantity units, defaulting to 1.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/signal/unit" \  -H "Content-Type: application/json" \  -d '{    "customerId": "cus_abc123",    "agentKey": "seats",    "member": "dana@acme.com"  }'
{  "statusCode": 200,  "statusDetail": {    "status": "SUCCESS",    "message": "OK"  },  "result": {    "unitUsage": {      "id": "string",      "customerId": "string",      "unit": "string",      "agentKey": "string",      "billingMode": "ADVANCE",      "remaining": 0,      "customerCost": 0,      "member": "string",      "createdAt": "2019-08-24T14:15:22Z"    },    "rawId": "raw_4k8w2r"  }}
{  "statusCode": 202,  "statusDetail": {    "status": "SUCCESS",    "message": "Signal accepted for processing."  },  "result": {    "queued": true,    "messageId": "msg_2f4a1b8c",    "rawId": "raw_4k8w2r"  }}
{  "statusCode": 400,  "statusDetail": {    "status": "ERROR",    "message": "Request body must be valid JSON."  },  "result": {}}
{  "statusCode": 401,  "statusDetail": {    "status": "ERROR",    "message": "Invalid API key."  },  "result": {}}
{  "statusCode": 404,  "statusDetail": {    "status": "ERROR",    "message": "No customer with id \"cus_abc123\"."  },  "result": {}}
{  "statusCode": 409,  "statusDetail": {    "status": "ERROR",    "message": "Customer \"cus_abc123\" is archived."  },  "result": {}}
{  "statusCode": 422,  "statusDetail": {    "status": "ERROR",    "message": "No credit with agent key \"summarize\" exists in this workspace."  },  "result": {}}
{  "statusCode": 500,  "statusDetail": {    "status": "ERROR",    "message": "Could not complete the request."  },  "result": {}}

Record wallet POST

Debits the customer's wallet at the model's provider cost. No `agentKey` — this meters money, not a named entitlement — and no `composite`. The wallet may go negative; a signal is never refused for lack of funds. If the model has both cache-read and cache-write rates, `cacheTokens` carries the cache-**read** tokens only (billed at the cache-read rate); send cache-write tokens separately as `cacheWriteTokens`.

Complete composite POST

Closes and bills ONE occurrence of a composite (a distinct tag value). Required even for outcome-tagged occurrences. Gated on every credit/outcome/unit the composite is restricted to having reported under the same value. Calling early isn't an error: it answers `422` but parks and completes itself once the rest lands.

customerId?string

Customer id. Required unless externalId is sent.

Length1 <= length
externalId?string

Your own id for the customer, instead of customerId. Signals are processed asynchronously, so one matching no customer is accepted and then left Pending with a 404 reason — create the customer and retry it.

Match^[A-Za-z0-9-]{1,32}$
Length1 <= length <= 32
member?string

Member email this signal is attributed to; must belong to the customer. Matched case-insensitively.

idempotencyKey?string

Dedupes retries — a repeat request carrying the same key returns the original signal's result instead of recording a duplicate. Scoped per organisation AND per meter, so one key reused across /signal/credit and /signal/wallet is two independent keys, not a collision. See Async, flushing & reliability.

Length1 <= length <= 255
agentKey*string

The unit's stable agent key, matched EXACTLY (keys are stored lowercased). The only accepted identifier — the display name is not, so renaming a unit never redirects a live integration.

Length1 <= length
quantity?integer

How many units this one report covers. Optional — omit it and the report counts as 1, which is what a caller sending one unit per call has always done. Whole numbers only, capped at 1,000,000 so a stray zero can't draw down an absurd allowance in one shot. On an ADVANCE unit the draw is all-or-nothing: if fewer than quantity remain the call is refused in full with a 422, never partially filled. On an ARREAR unit the cycle's invoice prices the SUM of quantity over the window, not the number of calls.

Range1 <= value <= 1000000
Default1
composite?

Composite tag. The property NAME is the composite's refId and the value is your own correlation id — { "voice_ai": "call_5f3a" } groups this signal into the voice_ai occurrence for call_5f3a.

Because the tag is nested under composite, a composite's refId can be any name — even one like model or status — without clashing with a real field of the signal.

A tag naming no live composite is ignored and never fails the signal — the signal carries money, the tag only decides which row of a report it lands in.

custom?

Free-form metadata, stored as sent with this unit report and returned as custom by GET /signal/usage-log.