Workflows and outcomes
A workflow meter lets you charge for what your product achieves rather than for the activity behind it: a support ticket resolved, a meeting booked, a contract reviewed. It groups the events of one piece of work into a workflow, gives each finished workflow exactly one outcome, and emits a derived event that prices can charge for. Your code only sends ordinary events; the rules that decide what counts as a result live in Paid.
Use a workflow meter to:
- Bill for results by putting a usage price on each outcome, such as $1.50 per resolved ticket.
- Bill a whole run once, however many model calls and tool calls it took, by grouping on
correlationId. - Report outcomes next to the activity behind them with usage summaries, grouped by
outcome.
Workflow meters are in the meters=v1 private beta: send Paid-Beta: meters=v1 with each request.
How a workflow works
- It opens with the first event that carries a new
identifiervalue. There’s no start event. - It collects every event the meter selects with that value, for the same customer and product.
- It closes when its close event arrives, such as
ticket.closed, or when its timeout runs out. - It gets one outcome: the first outcome, in the order you list them, whose conditions all hold.
- It becomes a derived event named after its outcome, which prices charge for.
A workflow is billed in the period it closes, not the one it opens in.
Create a workflow meter
Litware’s AI support agent works tickets for Northwind Traders. Litware charges $1.50 for each ticket the agent resolves and 25¢ for each one it escalates to a person. This meter groups events by ticket ID and classifies each closed ticket:
API
Dashboard
Create a meter with measure.type: "workflows", the path that groups events, how workflows close, and the outcomes.
Litware’s code doesn’t decide outcomes or quantities. It sends ordinary events with the ticket ID in the payload, such as this one when the agent hands a ticket to a person:
Choose the identifier
identifier is the path whose value groups events into one workflow, such as correlationId or payload.ticketId. Use correlationId for agent runs and conversations you already tag with one.
A workflow belongs to one meter, customer and product, so the same ticket ID for two customers makes two workflows. Events that don’t carry the identifier are ignored by the meter and counted in health.missingIdentifier24h. The meter’s eventNames or eventNamePattern, and its filters, decide which events can join a workflow.
A workflow’s customer unit is set by its first event. A later event for the same workflow that names a different unit fails with workflow_unit_conflict.
Close workflows
close needs at least one of:
onTimeout decides what happens to a workflow that times out: close gives it an outcome like any other, and discard drops it so it’s never billed. Timed-out workflows are counted in health.timedOut24h.
Define outcomes
Each outcome has a key and a list of conditions, all of which must hold. Outcomes are ordered and the first match wins, so every workflow has exactly one outcome and is billed once. A ticket whose last event has status: "resolved" is resolved even if it was escalated along the way, because resolved is listed first.
catchAll comes after every outcome and handles workflows none of them matched. Its action is discard, the default, which bills nothing, or emit, which emits them under its key (everything_else by default) so you can price them too.
With no outcomes and "catchAll": { "action": "emit", "key": "conversation_completed" }, every closed workflow becomes a conversation_completed event: a simple way to charge per completed conversation.
Shape the derived event
derivedEvent.quantity sets how much each workflow counts for:
Each can take divideBy and round (up, down or nearest), and filters to count only some of the workflow’s events. To bill whole hours of effort from minutes:
A ticket with 95 minutes of effort counts as 95 ÷ 60 = 1.583…, rounded up to 2 hours.
derivedEvent.payload adds named fields computed from the workflow’s events, to break reporting down by them. Each value is one of eventCount, sum, min, max, average, first, last, duration, openedAt, closedAt or composite:
Price outcomes
A usage price on a workflow meter names the outcome it charges for in usage.outcome. Litware creates two prices on support_tickets: one for resolved at 150¢ and one for escalated at 25¢. usage.outcome is optional when the meter emits only one outcome. A rate card can also match on outcome.
An outcome with no price is free but still recorded, and listed in the meter’s health.unpricedOutcomes. A workflow is priced at the price in effect when it closes.
Derived events
Each derived event carries a derived block saying which meter and outcome produced it, when the workflow opened and closed, and whether it closedBy a close event or a timeout. Its quantity is what the workflow counts for:
Prices and usage summaries read derived events. Meters never do, so one meter can’t count another meter’s output and bill the same work twice.
How it bills
In November, Litware’s agent works 1,275 Northwind tickets that close. The prices are 150¢ per resolved ticket and 25¢ per escalated ticket:
Northwind pays 151,500¢ + 4,500¢ = 156,000¢, or $1,560.00, for 1,190 billed tickets. A ticket opened on 30 October and closed on 2 November is among them, because it closed in November.
Check a workflow meter’s health
Workflow meters add these counters to the meter’s health:
Change or retire a workflow meter
Everything that decides what’s billed, including the identifier, close rules, outcomes and quantity, is fixed when you create the meter. To change it, create a new meter, create prices on its outcomes, and amend the orders that should use them. See Change or retire a meter.