Usage summaries
A usage summary shows how much of something a customer used over a period, next to what they paid for it: the quantity a meter measured, and the money invoiced, credits spent or commit drawn down for that quantity. One call can cover several meters, so you can show attempts and results side by side, such as 1,240 tickets worked and 1,010 resolved. Summaries are calculated when you ask for them, so there’s nothing to create or keep in sync.
Use usage summaries to:
- Report on your business: usage and revenue per customer, product, outcome or model, over hours, days, months or billing periods.
- Reconcile invoices with
basis=invoice, whose figures add up exactly to the usage charges on your invoices. - Show customers their usage in your own product, with what they spent and in what form. See Show customers their usage.
Usage summaries are in the usage_summaries=v1 private beta: send Paid-Beta: usage_summaries=v1 with each request.
How usage summaries work
You ask for a time range, a bucket size and the meters you want. Paid returns one row per bucket, per meter, per combination of the values you group by. Each row has:
For an event meter, quantity is the meter’s aggregation within the bucket. For a workflow meter, it’s the quantities of the workflows that closed in the bucket.
List usage summaries
Litware wants September’s support tickets for Northwind Traders, split by outcome, to check against the month’s invoice:
API
Dashboard
List usage summaries with a range, a granularity and the meters you want.
Money in a summary is an integer in minor units: 61800 is $618.00, for 412 resolved tickets at 150¢. The 64 escalated tickets at 25¢ come to 1,600¢, or $16.00.
Choose what to summarise
groupBy takes up to 3 of meter, customer, customerUnit, segment, product, outcome (workflow and single-event meters only), or a path from an event meter’s own groupBy, such as cost.inference.model. Without it, each bucket has one row per meter. With segment, a customer in two segments counts in both groups, so the groups can add up to more than the total, and customers in no segment are grouped under null.
The list is paginated with limit and cursor, like every list. It also returns asOf, when the figures were calculated, and a revision that pins every page of the list to the same figures.
How spend is paid
spend.parts lists each way the usage was paid for. Each charge is exactly one part:
invoicedTotal adds up the invoiced and overage amounts, and is null if they’re in more than one currency. Adding the value of the credits and overage parts gives the credits burned, which matches the credit ledger. New part types may be added, so skip any type you don’t recognise.
spend is null for a meter no price charges for. Usage on a non-billable unit is included, with no parts and a zero invoicedTotal.
How it bills
Adatum sells video analysis as prepaid credits, in a credit currency video_credits with a conversion of 1¢ per credit. Its video_minutes meter is priced at 2 credits a minute. Credit amounts are in the credit currency. In September, Brightrail analyses 1,800 minutes of video with 3,200 credits left on its balance:
The summary row for the month shows both parts:
Credits burned are 3,200 + 400 = 3,600, the same as the ledger shows for September.
Usage or invoice basis
basis decides which time a charge is bucketed by:
With basis=invoice, a month’s figures add up exactly to the usage charges on that month’s invoices. They don’t include recurring fees, taxes, credit purchases, percent-of fees or commit shortfalls, which aren’t usage. To reconcile Northwind’s October invoices:
Non-additive meters
Meters that take the max, min, average or latest of a field, or count distinct values with uniqueCount, return additive: false. Their buckets can’t be added up: 30 days of distinct daily users aren’t the month’s distinct users. For the figure the customer was billed, use granularity=billingPeriod.
Show customers their usage
Call usage summaries from your backend for the signed-in customer, and show the result in your own product. Never call the API from a browser: your API key must stay on your server. A daily view of the last week, per meter:
Pair summaries with credit balances to show what’s left, and credit grants to show when the next refill is due. Rows are provisional until the bucket’s charges are settled, so label recent figures as estimates.