When clients pay per outcome, your event counter is the invoice
Billing reconciles usage at the end of the period, while quotas must be checked on every event, so they are two systems running at two speeds.
In brief
- Stripe's basic billing meters reconcile usage only at invoicing, so customers can overspend their credits mid-period. Enforcing a quota requires a separate entitlement layer that runs in real time.
- Usage pipelines deliver each event at least once by default. Without an idempotency key and a deduplication rule, customers get charged twice.
- With outcome-based pricing, the hardest part is defining the outcome. That definition has to become code, traceable from the product event to the line on the invoice.
It is the last week of the billing period, and the customer has sent a screenshot of their own dashboard. The support agent you deployed “resolved” far fewer conversations than the invoice says. They are not asking about the model or the prompt. They want to know why the invoice shows more resolutions than they can count themselves.
For a forward deployed engineer, this is the moment billing stops being finance’s problem. When customers pay per token or per outcome, every event your code emits is money. A wrong counter means a wrong invoice, and trust drains away faster than it does after any technical bug.
The job is to connect the customer’s systems to billing so that the counts are right and the quotas hold. And when the customer challenges a number, you have to be able to show where it came from.
Billing and entitlements answer different questions
Billing answers “how much do we charge?”. Entitlements answer “is this customer still allowed to keep using it?”. The two sound alike, but they run at entirely different speeds.
Stripe’s documentation is explicit that basic usage-based billing reconciles usage only at invoice time. Throughout the period, neither the customer nor your team can see a running credit balance or running usage total.
Stripe also warns that with prepaid credits in basic mode, customers can use more than their balance mid-period. For new integrations that need real-time balances and credit burn-down, Stripe points users to Metronome.
The consequences are concrete. If the contract says “10 million tokens a month”, the example OpenMeter uses to describe a metered entitlement, you cannot wait for the invoice to learn that the customer has gone over. You need a check that sits in the request path and keeps a balance for each customer.
OpenMeter links usage events to entitlements through a “subject key”, the field in the event that says who used the feature. It sounds like a detail, but it is where many integrations break. If the subject key is a user ID while the quota is set per workspace, the balances will never match.
One conversation, three actions, one charge
Take a concrete case. Say the customer pays for each conversation the agent resolves, on a model like Intercom Fin. Intercom defines a billable resolution in two ways: the customer confirms the issue is dealt with, or the customer leaves the conversation without asking for further help. The second case is called an “assumed resolution”.
Intercom has one more rule: each conversation counts as a single outcome, even when the agent takes several actions. Suppose that in one conversation the agent looks up an order, changes the delivery address and sends a discount code. If the code emits one event per action, the customer is billed three times for something that should be billed once.
The billing unit therefore has to be the conversation, not the action. The sketch below shows how to build the event:
def build_resolution_event(conv):
# Only bill once the conversation is closed and matches the contract definition
if conv.status != "closed":
return None
confirmed = conv.customer_confirmed
assumed = conv.customer_left and not conv.asked_for_more_help
if not (confirmed or assumed):
return None
return {
"event_name": "resolution", # must match the name configured on the meter
"customer_id": conv.billing_customer_id,
"value": 1, # one outcome per conversation
"identifier": f"resolution:{conv.id}", # stable idempotency key
"timestamp": conv.closed_at,
"trace": {"conversation_id": conv.id, "rule": "confirmed" if confirmed else "assumed"},
}
Every field is there for a reason. Stripe requires a configured meter, after which meter events must carry the event name, the customer ID, a numeric value and, optionally, a timestamp. The identifier is built from the conversation ID rather than the send time, so however many times it is resent, it remains a single outcome.
The trace field is the one most people skip. Stigg, a pricing infrastructure provider, argues that every outcome event must be traceable from the product to the invoice. When a customer sends a dashboard screenshot like the one above, trace tells you which rule each resolution was billed under.
One place to check early is the “assumed” group: those outcomes are inferred from the customer leaving, so the customer’s own dashboard may not record them as resolutions.
The counter must survive retries, late events and peak load
Stigg writes that usage pipelines are designed to deliver each event at least once. Duplicates, in other words, are certain; only their timing is unknown.
Stripe likewise recommends idempotency keys so that network latency or other errors do not cause an event to be reported twice. Deduplicate at both ends: in your own outbox table and through the identifier sent to the provider.
The second risk is time. Stripe processes meter events asynchronously, so the usage total on the upcoming invoice may not immediately reflect events you have just sent.
Timestamps also have to be close enough to the present. Most important, usage must be reported before that period’s invoice is finalized; otherwise an event may still be accepted but never billed.
The third risk is throughput. Stripe’s v1 meter event endpoint is limited to 1,000 calls per second per Stripe account. A customer running the agent across thousands of parallel conversations, with one event sent for every LLM call, will hit that ceiling quickly.
There are two ways out: pre-aggregate by customer and time window and send the totals, or use the v2 API’s stream.
Finally, there are malformed events. Stripe surfaces invalid events through an error webhook and expects you to fix and resend them. If nobody listens to that webhook, bad events quietly disappear. Revenue leaks, and you only find out at end-of-period reconciliation.
The order of work at the customer site
The first step is not code. Sit down with the customer and whoever owns pricing, and write the definition of “one billable unit” as a sentence you can test.
For example: “conversation closed, customer confirmed or left without asking for more, at most once per conversation”. Intercom’s definition shows that the rules for recognizing an outcome live inside the definition itself, and each such rule becomes an if branch in the code.
Next, choose a subject key that matches the level at which the contract sets quotas, such as workspace, organization or customer. Then build an outbox: events are written to your database first, with an idempotency key, and a worker pushes them to billing. That worker needs to know the invoice finalization date so it can raise an alert when the queue falls behind close to it.
The entitlement layer runs in parallel. Stigg describes outcome-based entitlements as a credit balance drawn down after each confirmed outcome and rechecked on every event. Put that check in the request path, reading from a real-time balance, rather than asking a billing system that only reconciles at the end of the period.
Last comes a daily reconciliation job: count by trace in your own system and compare against the billing totals. A small, steady gap usually means late events. A growing gap usually means retries without an idempotency key.
The mistakes that produce wrong invoices
The most common mistake is building the identifier from the send time, or from a UUID generated afresh on each retry. The idempotency key then exists in name only. The second is using the upcoming invoice as the balance for blocking customers. As Stripe warns, that number lags, and customers can go over mid-period.
The third is emitting events per action when the contract bills per outcome. The fourth is having nobody listen to the error webhook. The fifth is harder to spot: not storing the rule that made an event billable. When the customer disputes the charge, you have nothing to show them.
For your career, this is a skill worth presenting precisely. When reading FDE job postings at AI companies that sell on usage, look for the phrases “usage-based billing”, “metering” and “entitlements”.
On a CV, a line such as “designed an idempotent usage pipeline, reconciled daily against invoices, enforced quotas in real time” carries far more weight than “integrated Stripe”.
An exercise for this week
Take any product flow you are working on and write its definition of “one billable unit” in a single sentence. Then write a test that simulates a conversation with three actions and two retries. The test passes only if the system records exactly one event, with a trace an outsider can understand.
Do that before the customer asks, and the end-of-period call gets much shorter: you simply open the reconciliation table and show them.
Was this article useful?
Thanks for the feedback!