Events
An event is one unit of usage. The minimal shape:- Idempotency is enforced, not advisory. A repeated
eventIdempotencyKeyreturns409 Conflict. Generate one unique key per logical event (a UUID is fine) and you can retry sends safely. - Customers resolve by your ID.
customerReferenceIdis the same ID you used when creating the customer. - Cost fields are optional but are the margin story. Events accept
model,modelProvider,costUnits(e.g. tokens),inputTokens,outputTokens, andcostAmount. Stamp what the usage cost you, and per-customer margin falls out of the same ledger that bills. - Revenue is computed at ingestion from the plan’s pricing rule and stored on the event — not reconstructed at invoice time.
Entitlements
meta.reason says why (no subscription, entitlement revoked,
limit reached). Checks fail closed — no subscription, unpaid first
invoice, or missing configuration all mean allowed: false.
The intended pattern in your request path: