Send events
An event is a record of something you did for a customer: a model call, a document reviewed, a ticket reply. You send Paid what happened and who it was for, and meters decide what part of it is billable. Every event carries a dedupeKey of your own, so you can resend it as often as you need and it’s still counted once.
Use events to:
- Bill for usage by sending the raw facts and letting a meter and a price turn them into charges.
- Bill for results by grouping the events of one piece of work with a
correlationId, for a workflow meter. - Track your margin by adding what each event cost you to produce, as cost lines.
- Spend reserved credits by settling a credit hold with the event for that work.
Events are in the events=v1 private beta: send Paid-Beta: events=v1 with each request.
How events work
- You send what happened. Name the customer and product by your own IDs or Paid’s, add a
dedupeKey, and put any detail you might want later inpayload. - Paid accepts it once. It resolves the customer and product to Paid IDs and drops any event whose
dedupeKeyit has already seen. - Meters read it. Each meter whose event names and filters match the event measures it.
- Prices bill it. A usage price on the customer’s order turns each meter’s quantity into a charge.
Send events in as raw a form as you can, and decide what’s billable in Paid. That keeps commercial logic out of your code: to charge for something else, you change a meter and a price, not what you send.
Send an event
Clausebase reviews contracts for law firms. Each time it finishes a document for Halberd LLP, it sends one document.reviewed event with the page count:
API
Dashboard
Create an event for each piece of work.
The response returns customer and product as Paid IDs, whichever IDs you sent, and keeps the references exactly as you sent them in sentAs. timestamp is when the work happened; createdAt is when Paid received it.
To check what arrived, retrieve the event by its ID, or list events filtered by customer, correlationId or dedupeKey. A new event can take a few seconds to appear in the list.
A meter reads payload fields by path, such as payload.pages. A value a meter sums or compares must be an integer or a decimal string, such as "12.5": see Meters.
Retries and duplicates
dedupeKey makes an event unique. Use an ID your system already has for the work, such as the document or message ID, so a retry carries the same key.
If Paid has already accepted an event with that dedupeKey, it ingests nothing and returns the original event with duplicate: true and status 200 instead of 201. It isn’t an error, so you can retry a failed or timed-out send as often as you need without counting anything twice.
dedupeKey is separate from the request-level Idempotency-Key header. The header makes one request safe to repeat; dedupeKey makes one event count once, whichever request or batch carries it.
Send events in batches
To send many events at once, create a batch of events: up to 1,000 events, each with the same fields as a single event.
Items succeed or fail independently, and the response is always 200. data holds one result per item, in input order, with its index, dedupeKey and a status:
summary counts each status as ingested, duplicates and failed. Resend only the failed items once you’ve fixed them. Resending the whole batch is also safe, because the accepted items come back as duplicates. A request body that’s too large fails as a whole with status 413.
Group related events
A correlationId groups the events of one run, conversation or job, such as every model call and tool call an agent makes to answer one ticket. The ID is yours: Paid doesn’t create it, doesn’t need it registered first, and doesn’t require it to be unique. Groups are scoped to a customer, so the same ID sent for two customers makes two groups.
Use it to:
- bill a whole run once, with a workflow meter whose
identifieriscorrelationId - bill per conversation, with a meter that counts distinct correlation IDs
- add up the cost of a run across its events
- tie a credit hold to the run that spends it
Events for customers you haven’t created
If an event names a customer ID Paid doesn’t know yet, Paid creates a draft customer under that ID and accepts the event, so no usage is lost. Drafts are never billed. When you create the customer with the same externalId, the draft becomes a real customer and keeps its usage. If the ID belongs to another system, add it as a customer alias of the right customer instead, which merges the draft into it.
An event that names an unknown customer unit is accepted too, but no unit is created: its usage is held until you create the unit with that externalId. An unknown Paid ID, such as a cus_ ID that doesn’t exist, isn’t a draft: the event fails with reference_not_found.
Settle a credit hold
Name a credit hold in creditHold on the event for the work you reserved credits for. When the event’s spend posts, the hold is settled.
If the hold is no longer active, because it expired, was released or was settled by another event, the event is still accepted and billed as if it named no hold. Its warnings list resource_not_active, with param naming creditHold:
Non-billable usage
Events for a customer unit marked billable: false, or for any unit under one, are recorded and reported but never billed. Use this for a customer’s development or QA environments. See Customer units.
How it bills
Clausebase meters the pages in each document.reviewed event with a pages_reviewed meter that sums payload.pages, and prices it on graduated tiers: 12¢ a page for the first 50,000 pages each month, 8¢ up to 200,000 and 5¢ above that. Price amounts are in cents. In November, Clausebase’s service sends Halberd’s events, retrying a few after timeouts:
The three retried sends changed nothing: each came back with duplicate: true, and its pages were counted once.
Change an event
The API records events but has no operation to change or delete one. Send a late event with its real timestamp: usage summaries on the usage basis show it in the period it happened, and invoices that were already issued don’t change. To change what an event is billed for, change the meter or the price, not the event.