v1
latestOpenAPI 3.1.02026-08-042453938.9 KBRecord usage and charge
Record a billable usage event and immediately charge the customer.
Requires a secret key (sk_*) with at least the OPERATOR role.
This endpoint waits for on-chain confirmation before returning, ensuring the charge is settled. For faster responses, use POST /v1/usage/async.
x402 Payment Flow: If the customer has insufficient balance, returns 402 with payment headers. The client can sign a payment with their session key and retry with X-Payment-* headers to complete the charge.
Idempotency: Include an idempotencyKey to safely retry requests without duplicate charges.
Request body
Example request
{
"customerId": "cus_abc123def456",
"externalCustomerId": "user_42",
"stripeCustomerId": "cus_NffrFeUfNV2Hib",
"usageType": "api_call",
"quantity": 100,
"units": "API calls",
"description": "Eligibility check for Pharmacy ABC (workflow: insurance_verify)",
"idempotencyKey": "req_20240115_abc123",
"metadata": {
"endpoint": "/v1/chat",
"model": "gpt-4"
}
}Response
Usage recorded. Either an on-chain charge was created (charge object populated) or the customer has no on-chain address and the request was auto-promoted to internal/visibility mode (charge=null, mode=internal).
Example response
{
"success": true
}