Graduated pricing with an annual minimum
Brieflens runs an agent that reviews contracts and flags risky clauses. It charges per page reviewed, cheaper at volume: 12¢ a page for the first 50,000 pages a month, 8¢ up to 200,000, and 5¢ above that. Its customer Umbrella Legal, a law firm, signs a $120,000 annual minimum with 10% off list, and wants its usage split by practice group: litigation, M&A and employment.
This example uses:
- Products for what Brieflens sells
- Meters to count pages reviewed
- Prices for the graduated per-page rate
- Customers and customer units for the firm and its practice groups
- Orders carrying the discount and the commit for the minimum
- Events for each document reviewed
- Usage summaries for reporting
The calls below show only the request body. Every request also sends the headers listed under request headers: Authorization, Paid-Version, the Paid-Beta opt-in each endpoint requires (for example orders=v1 for orders and events=v1 for events), and an Idempotency-Key on writes so you can retry them safely.
Money amounts on prices are decimal strings in cents ("12" is 12¢). Amounts on commits are integers in cents (12000000 is $120,000.00).
Setup
These calls run once, when Brieflens sets up its catalog.
Create a product for document review:
Create a meter that sums the pages field of every document.reviewed event:
Create a usage price on that meter with graduated tiers. Each tier is charged at its own rate, and the tiers reset every billing period (tierScope defaults to billingPeriod):
The response returns the price’s ID, prc_4Lm9Tz in this example.
Signing Umbrella Legal
Create an order for the 2027 term. It carries the page price, Net 45 payment terms, the 10% discount in negotiatedPricing and the $120,000 minimum in commits. Both are created with the order and apply to this order only:
The discount has no startsAt or endsAt, so it lasts as long as the order. With period: "term", the minimum is measured once across the whole year rather than each month.
The order is created as a draft. Activate it to start billing; the request has no body:
Practice groups
Model the practice groups as customer units. Create the root unit for the firm first:
Then one unit per practice group under it:
And the same for m-and-a (M&A) and employment (Employment).
Units attribute usage; they don’t change pricing. The graduated tiers, the discount and the minimum all apply to the firm’s total pages, once.
Sending usage
Send an event for every document reviewed, naming the practice group in customerUnit. Use the document’s ID as the dedupeKey, so a retried send isn’t counted twice:
To send many documents at once, use create an event batch with up to 1,000 events.
The month
In January, Umbrella Legal’s lawyers review 180,000 pages. The tiers split them as follows, and the 10% discount comes off each tier:
- Graduated: 50,000 × 12¢ = $6,000.00 and 130,000 × 8¢ = $10,400.00. No pages reach the 5¢ tier. In February the count starts again at the first tier.
- Discount: 10% off $16,400.00 is $1,640.00, leaving $14,760.00 on the invoice.
- Minimum: the $14,760.00 counts toward the $120,000 term minimum at the discounted price. Retrieve the commit (
GET /v1/commits/cmt_3Rv8Wd) to see the running total inbalance: after January,consumedis1476000andremainingis10524000.
If Umbrella Legal’s spend for the year ends at $112,300.00, the closing invoice adds a $7,700.00 line for the shortfall ($120,000.00 − $112,300.00). At $120,000.00 or more, it adds nothing.
Reporting by practice group
List usage summaries with basis=invoice to get rows that match each invoice exactly. This basis reads the posted usage charges, so a late adjustment shows up on the invoice that carried it:
Grouping by customerUnit splits the same pages and spend by practice group. In January the rows show litigation at 96,000 pages, M&A at 61,000 and employment at 23,000, which add up to the 180,000 pages and $14,760.00 on the invoice. To report on one practice group alone, pass customerUnit=litigation instead of grouping.