Skip to main content
After a signature verifies, and before your API does any work, ask ZeroClick whether the buyer’s plan covers what this request will use. That is the allowance check: POST /v1/usage/check with the request’s zcRequestId and the declared usage. Checking records nothing and burns no credit; it is a pre-gate, not a charge. For the model behind it, see usage and allowances. The SDK guard runs the check for you, immediately after verification:
In Go, the Meter middleware wraps Guard and the usage settlement in one. When you need the decision in your own handler, call Guard directly.

Declare what the request will use

Each usage item names a meter and takes one of three forms: Before any network call, the SDK rejects an item that declares both quantity and maxQuantity. A check takes 1 to 20 items, one per meter. The SDK rejects duplicate meters too.

Read the decision

guard returns a decision, not an exception. A buyer who can’t pay is an expected event:
  • Deny carries a ready-to-return response: the 401 for a failed signature, the exact 402 payment_required body for a business denial, or the 503 under a fail-closed outage policy. Return it unchanged (decision.response in TypeScript and Python, result.Response in Go). Do no work. The reason field carries one of the seven denial reasons, listed at errors.
  • Allow carries the verified context (zcRequestId, zcAgentId) and an allowance status:

When the allowance API gives no answer

The check sits in front of every billable request, so its timeout is short: 1.5 seconds by default (checkTimeoutMs / check_timeout_seconds / CheckTimeout). When it expires, or the API is unreachable or failing, your configured policy decides: The policy applies only after a signature has verified: a fail-open allowance policy never becomes a fail-open signature policy. The Go SDK further restricts the policy to genuine no-answers:
The TypeScript and Python SDKs route every allowance API error through the policy, including 4xx responses and unrecognized denial reasons. Under the default allow policy, monitor onAllowanceUnavailable for repeated incidents: a persistent 4xx such as a revoked key means you are serving every request unbilled. Each SDK’s errors page documents its exact classification.
Set onAllowanceUnavailable (and, in Go, Logger) to record every incident the policy absorbs. A fail-open that is also silent is invisible unbilled traffic:

Call the allowance API directly

For flows where verification and the check live in different layers, call the check yourself with a zcRequestId from an already-verified context. The response is { "allowed": boolean, "reason": <denial reason or null> }. Building the 402 from a denial is then on you (paymentRequired / payment_required / PaymentRequired construct the exact body).
Unlike guard, the direct check surfaces outages as errors instead of applying the policy. It runs under your own cancellation (an optional { signal } in TypeScript, the caller’s context in Go). Once a request is allowed, serve it. Then settle the usage.