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

API Reference

Webhooks

How webhook events reach your server — the request, verifying the signature, responding, retries and duplicates.

Webhooks push events to your server instead of you polling for them. When an event is triggered — a wallet balance changes, a customer is added, a subscription renews, an invoice is paid, a card is refunded — Clocknext sends an HTTP POST with a JSON body to every endpoint subscribed to it, signed with that endpoint's secret.

You register endpoints, pick their events, and copy their signing secret in Settings → Webhooks. There is no API for managing endpoints yet — this page covers receiving events.

Events

Each event has its own page with its full payload, under Webhooks in the API reference. You pick the events for each endpoint in Settings.

Wallet

EventTriggered when
wallet.balance.updateA customer's Wallet balance increases or decreases, except through usage signals.
wallet.balance.dropA customer's Wallet balance falls from above their low-balance threshold, or the endpoint's threshold if they have none, to at or below it. The threshold is in USD or a percentage of the plan's Wallet amount per cycle.

Both events watch the customer's ordinary Wallet only. Changes to the Reserved Wallet don't trigger them.

The low-balance threshold behind wallet.balance.drop is either a USD amount or a percentage (0 to 100) of the plan's Wallet amount per cycle. The event's data carries threshold for a USD level, or threshold_percentage for a percentage level: exactly one of the two is present. A percentage level applies to advance-billed Wallets only; with no active plan Wallet amount, it sends nothing.

When the org has the Reserved Wallet on, wallet.balance.drop also carries reserved_balance: the Reserved Wallet's live balance, in USD. The threshold is still checked on the main Wallet only.

Not triggered by usage signals

wallet.balance.update isn't triggered when a usage signal charges the Wallet. To read a balance, call Get a customer's balances. wallet.balance.drop is still triggered when a signal takes the balance to the low-balance threshold.

Customer

EventTriggered when
customer.createdA customer is added, in the dashboard or through the API.
customer.updatedA customer's details change. updated_fields names the fields that changed.
customer.archivedA customer is archived.
customer.restoredAn archived customer is restored.

Subscription

EventTriggered when
subscription.createdA plan is recorded for a customer. It starts once it is due.
subscription.activatedA subscription starts: its entitlements are live.
subscription.renewedA subscription moves on to its next billing period.
subscription.on_holdA renewal invoice is unpaid. The customer keeps last period's entitlements until it is paid or the hold ends.
subscription.resumedA held renewal is paid and the hold clears.
subscription.cancellation_scheduledA subscription is marked to end at the end of its paid period. It keeps working until then.
subscription.cancelledA subscription ends. reason is CANCELLED, PLAN_CHANGE, HOLD_EXPIRED or UNPAID.

Package

EventTriggered when
package.addedA package on a subscription becomes active: its invoice is paid or recorded as paid.
package.removal_scheduledA package is removed with atPeriodEnd: true. It keeps working until the end of the plan's billing cycle.
package.endedA package ends. ended_reason is REMOVED, INVOICE_VOIDED, PLAN_CHANGED or SUBSCRIPTION_CANCELLED.

Invoice

EventTriggered when
invoice.createdAn invoice is issued. A package attach invoice carries package_invoice.
invoice.paidAn invoice is marked paid, by a payment recorded by hand or through a payment gateway.
invoice.voidedAn invoice is voided, by hand or automatically.

Payment

EventTriggered when
payment.succeededMoney arrives: an invoice is paid, or the customer buys something in the customer portal.
payment.failedAn automatic card charge for an invoice is refused (declined, or the bank asks to confirm it).

Credit note

EventTriggered when
credit_note.createdA credit note is issued on an invoice: by hand, through the API, by a cancel with a refund, or by a plan change.
credit_note.voidedA credit note is voided while its invoice is still open. The invoice owes the amount again.

A credit note is a document; it moves no money by itself. To know when an invoice is credited in full (for example, to take access away), compare invoice.credit_notes_amount with invoice.amount in credit_note.created: when they are equal, every cent of the invoice is credited. That does not mean the money is back on the card — see the refund events below.

Refund

EventTriggered when
refund.createdA card refund is asked of the payment gateway. The money is not on the card yet.
refund.succeededThe payment gateway confirms the refund to the card.
refund.failedThe payment gateway fails or rejects a card refund. The money goes into the customer's invoice balance.

Only refund.succeeded means the money reached the card. refund.failed has status FAILED or REJECTED_IN_GATEWAY_REVIEW (Paddle's review said no); use status to decide and failure_reason to show. After a failure the money is in the customer's invoice balance, so you can ask for the refund again or tell the customer.

Tick the new events on existing endpoints

An endpoint gets the credit note and refund events only after you tick them in Settings → Webhooks. Endpoints that existed before these events don't get them on their own.

Events that come together

One change can trigger more than one event. Each event has its own id.

  • An invoice is paid. invoice.paid, then payment.succeeded when the invoice was for more than 0. A paid renewal that was on hold also triggers subscription.resumed.
  • A subscription moves on to its next period. subscription.renewed. When the renewal invoice is not paid yet, subscription.on_hold follows. The renewal invoice has its own invoice.created when it is issued.
  • An invoice is voided and its subscription ends. invoice.voided and subscription.cancelled. When many invoices are voided at the same time, each invoice gets its own invoice.voided.
  • A portal buy (a top-up, credits, outcomes or units). payment.succeeded with item set and invoice null. A plan upgrade in the portal pays an invoice instead, so it triggers invoice.paid and payment.succeeded with invoice set.
  • Packages are added to a subscription. invoice.created for their invoice. When it is paid, invoice.paid, payment.succeeded and one package.added for each package.
  • A refused card. payment.failed is triggered once for each invoice and card. Automatic retries with the same card do not trigger it again.
  • A credit note that refunds the card. credit_note.created, then refund.created. When the gateway answers at once, refund.succeeded or refund.failed follows. A credit note that goes to the invoice balance or lowers an open invoice triggers no refund event. A credit note that covers an open invoice in full also triggers invoice.paid and payment.succeeded, after credit_note.created.
  • A refund split over 2 card payments. A refund from the invoice balance that goes back to 2 card payments triggers 2 refund.created, each with its own refund id, amount and invoice. Each then gets its own refund.succeeded or refund.failed.
  • A refund that fails late. A gateway can report a failure after the refund succeeded (Stripe up to 30 days later, or a Paddle reversal). Then refund.failed follows refund.succeeded for the same refund. refund.failed is final: nothing follows it.

All amounts are in USD (currency_code: "usd"). Invoice and payment events also have display_amount and display_currency_code: the amount in the currency the customer pays in. Refund events have charged_amount_minor and charged_currency_code instead: what goes back to the card, in whole minor units of the currency it was charged in.

The request

Every event is sent the same way, with three headers and the same envelope — only data differs between events:

POST /webhooks/clocknext HTTP/1.1
Content-Type: application/json
X-Clocknext-Signature: t=1791367200,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
X-Clocknext-Event-Id: evt_3f9a1c6e8b2d4f7a9c0e1b2d3f4a5b6c
X-Clocknext-Event-Type: wallet.balance.drop

{
  "id": "evt_3f9a1c6e8b2d4f7a9c0e1b2d3f4a5b6c",
  "event_type": "wallet.balance.drop",
  "triggered_at": "2026-10-07T14:02:51.093Z",
  "data": { … }
}

X-Clocknext-Event-Id and X-Clocknext-Event-Type repeat the body's id and event_type, so you can route a request before parsing it.

Verify the signature

Check every request before you trust it. The signature is an HMAC-SHA256, keyed with the endpoint's full signing secret (including the whsec_ prefix), over the string ${t}.${rawBody} — the timestamp, a dot, and the raw request body exactly as received.

  1. Split X-Clocknext-Signature on , and read the t and v1 values.
  2. Compute HMAC-SHA256(secret, t + "." + rawBody) as lowercase hex.
  3. Compare it to v1 with a constant-time comparison.
  4. Reject requests whose t is too old (for example, more than 5 minutes) to block replays.

Sign the raw body. Parsing the JSON and re-serialising it changes the bytes and the signature won't match. Each sample below does the same steps. In Node.js the @clocknext/sdk package does them for you; the other languages write them out. Pick your language:

import express from "express";
import { constructWebhookEvent, WebhookSignatureError } from "@clocknext/sdk";

const app = express();
const SECRET = process.env.CLOCKNEXT_WEBHOOK_SECRET!; // whsec_…

// express.raw keeps the body as bytes so the signature can be checked.
app.post("/webhooks/clocknext", express.raw({ type: "application/json" }), (req, res) => {
  let event;
  try {
    // Checks the signature and rejects events older than 5 minutes.
    event = constructWebhookEvent(req.body, req.header("x-clocknext-signature"), SECRET);
  } catch (err) {
    if (err instanceof WebhookSignatureError) return res.status(400).send("Invalid signature");
    throw err;
  }

  switch (event.event_type) {
    case "wallet.balance.update":
      // e.g. record the top-up or adjustment
      break;
    case "wallet.balance.drop":
      // e.g. email the customer to top up
      break;
    case "invoice.paid":
      // e.g. mark event.data.invoice.number paid in your own books
      break;
    case "subscription.cancelled":
      // e.g. turn off access; event.data.reason says why it ended
      break;
    case "credit_note.created":
      // e.g. take access away when event.data.invoice.credit_notes_amount equals event.data.invoice.amount
      break;
    case "refund.failed":
      // e.g. ask for the refund again, or tell the customer; event.data.refund.status says why
      break;
  }
  res.sendStatus(200);
});

app.listen(3000);

Respond, retries, and duplicates

  • Answer with any 2xx within 5 seconds. Anything else — a non-2xx status, a timeout, or a connection error — counts as a failed delivery. Do slow work after you respond.
  • Failed deliveries are retried automatically, 2 more times: after 30 seconds and after 2 minutes. Every attempt, and the HTTP status your server answered, is listed under Message Attempts on the endpoint's page, where you can also retry a failed delivery by hand.
  • The same event can arrive more than once. Retries reuse the event's id (and X-Clocknext-Event-Id), so record the ids you've handled and skip repeats.
  • Events can arrive out of order. Use triggered_at and the values in data (a balance, a status) rather than arrival order. For example, accept a refund.succeeded for a refund whose refund.created you haven't seen yet. For the current state, read it from the API — for example Get customer balances or Get a subscription.
  • Disabled endpoints get nothing. Events triggered while an endpoint is disabled are dropped, not saved for later.

Rotating the secret

Rotating an endpoint's secret in Settings takes effect immediately — every delivery after that, including retries of earlier events, is signed with the new secret. Update your server's secret straight away.

Your own customer ids

Give a customer an externalId — the id your product already uses — and name it by that instead of ours.

Record credit POST

Records one LLM call against a credit, named by `agentKey` (matched exactly, case included). The credit must be on the customer's plan, or covered by a composite on it. The price comes from the model's rates. Answers `202`; a signal that can't be counted stays `PENDING`. See [List raw signals](/docs/api-reference/signals/eventsListSignals).

On this page

EventsWalletCustomerSubscriptionPackageInvoicePaymentCredit noteRefundEvents that come togetherThe requestVerify the signatureRespond, retries, and duplicates