No. 57SaaS8 min read1,997 words
Usage-based billing for SaaS: metered and hybrid pricing
How to build usage-based billing for SaaS: choosing a metered or hybrid model, an exactly-once metering pipeline, syncing to Stripe, and preventing bill shock.
- Written by
- Lazy Devs
- Published
- Updated
- Sources
- Cited inline

Key takeaways · 05
The short version
- 01Usage-based pricing fits when both the value a customer gets and your cost to serve them grow with consumption. Hybrid pricing (a base fee plus metered overages) is usually the safest model because buyers can predict their bill.
- 02The hard part is not the billing provider but your metering pipeline: every billable event must be captured once, attributed to the right customer and meter, and assigned to the right billing period.
- 03Keep your own durable, append-only record of raw usage with a unique idempotency key per event. The billing provider is the invoicing engine, not your system of record.
- 04Report usage to the provider in aggregated batches with stable identifiers, and run a scheduled reconciliation that compares your totals with the provider's before invoices finalize.
- 05Prevent bill shock with a live usage meter in the product, threshold alerts and optional spend caps. Customers who can see the meter running rarely dispute the bill.
On this page · 09
Usage-based billing charges customers for what they actually consume (API calls, gigabytes stored, messages sent, seats plus overages) instead of a flat monthly fee. To build it well you need two things: a pricing model that matches how your product creates value, and a metering pipeline that counts every billable event exactly once, attributes it to the right customer and period, and stays in sync with your billing provider. The provider is the easy part. The counting is where revenue quietly leaks.
If you only need flat plans, start with our guide to implementing subscription billing the right way. This post is about the harder, increasingly common case where the numbers on the invoice depend on what the customer did.
When usage-based pricing beats a flat fee
Flat pricing is simple to build and simple to understand, and for many products it is the right answer. Usage-based pricing earns its complexity when both the value a customer gets and your cost to serve them scale with consumption. If a heavy customer costs you far more to serve than a light one, charging them the same flat fee means light users subsidise heavy ones, and eventually that math turns against you. Products built on metered infrastructure, such as AI features with per-token model costs, feel this most sharply.
| Model | How it charges | Strengths | Risks |
|---|---|---|---|
| Flat subscription | Fixed price per period | Predictable for both sides, simplest to build | Heavy users can be unprofitable |
| Per seat | Price per user | Easy to understand, grows with team size | Customers ration seats; weak link to value for automated products |
| Pure pay-as-you-go | Only what was used | Low barrier to start, scales with value | Unpredictable bills; revenue swings |
| Tiered or volume | Unit price changes at usage thresholds | Rewards growth, fair at scale | Harder to explain and to test at tier boundaries |
| Hybrid (base plus overage) | Fixed fee with an allowance, usage above it billed | Predictable base revenue, captures heavy use | Two systems to keep in sync |
| Prepaid credits | Customers buy credits that usage draws down | Cash upfront, natural spend control | Needs real-time balances and expiry rules |
The strongest default for most B2B products is hybrid: a base subscription that covers a predictable amount, plus metered charges beyond it. It gives you forecastable revenue and still captures more from your biggest users. Pure metered pricing is powerful but makes buyers nervous because they cannot predict the bill. Stripe's overview of usage-based pricing models walks through how each model is configured.
The decision is a business one before it is an engineering one. Pick the model that matches how your product delivers value, then build the machinery to bill it accurately. Get the order wrong and you end up retrofitting metering onto a pricing model that never suited the product.
Choosing your value metric
The value metric is the unit you charge for. A good one has four properties:
- Customers understand it without reading documentation.
- It grows with the value they get, so a bigger bill feels earned.
- You can measure it precisely at the moment it happens.
- Customers can predict and influence it, so they feel in control.
API calls, messages sent, documents processed and active records usually pass. Internal measures like CPU seconds often fail the first test unless your buyers are engineers. Fewer meters are better: every additional meter is another pipeline to build, another line to explain on the invoice and another source of disputes.
The hard part is accurate metering
The billing provider will happily aggregate usage and produce an invoice. The hard problem is upstream: counting what customers do correctly, at volume, without losing or double-counting a single event. That counting layer is your responsibility.
A usage event has to be captured when it happens, attributed to the right customer and meter, and recorded durably before it is aggregated into a bill. Four things make that hard:
- Volume. A busy product can generate a very large number of billable events. Writing each one to your billing provider inside the request path adds latency and runs into rate limits: Stripe's meter event endpoint, for example, is limited per account and to one concurrent call per customer per meter. You need a pipeline that buffers and aggregates first.
- Idempotency. The same action can be recorded twice through a retried request, a redelivered queue message or a worker that crashed mid-flush. Every event needs a stable, unique key so it is counted once.
- Attribution. Usage must be tied to the right account at the moment it happens. Account hierarchies, plan changes and moved seats can all shift the target. Billing the wrong account is worse than billing the wrong amount.
- Period boundaries. An event a second after the renewal moment belongs to the new period. Off-by-one errors at the boundary produce invoices that are subtly, persistently wrong. Store event time in UTC and define periods by the provider's period start and end, not by your server's local midnight.
A metering pipeline that counts once
A design that holds up for most products:
- Emit a usage event from the code that performs the billable action, with a deterministic idempotency key (for example, the request ID plus the meter name).
- Record it in an append-only usage table in your own database, with a unique constraint on that key. Duplicates are rejected by the database, not by hope.
- Aggregate on a schedule into per-customer, per-meter, per-window totals.
- Report those totals to the billing provider with a stable identifier per window, and mark them as reported.
- Reconcile your totals against the provider's before each invoice finalizes.
create table usage_events (
idempotency_key text primary key, -- e.g. request id + meter name
tenant_id uuid not null references tenants(id),
meter text not null, -- e.g. 'api_requests'
quantity bigint not null check (quantity >= 0),
occurred_at timestamptz not null, -- when the usage happened, in UTC
recorded_at timestamptz not null default now()
);
create index on usage_events (tenant_id, meter, occurred_at);
-- Recording is idempotent: a retried insert with the same key does nothing.
insert into usage_events (idempotency_key, tenant_id, meter, quantity, occurred_at)
values ($1, $2, $3, $4, $5)
on conflict (idempotency_key) do nothing;This is real backend infrastructure, not a billing settings screen, which is why it usually sits with API and backend engineering rather than with whoever set up checkout. At high volume the ingestion step usually moves to a queue and background workers so recording never slows the request that produced the usage.
Syncing usage to Stripe without drift
Once you count correctly, you report the numbers to your billing provider. With Stripe's basic usage-based billing, you send meter events containing the meter's event name, the customer, a value and an optional timestamp. Stripe's usage recording documentation lists the details that matter for a reliable sync:
- Each meter event has an
identifier. Send a stable one per aggregation window so a retried report is not counted twice. Idempotency keys work too. - Event timestamps must fall within the past 35 calendar days and no more than 5 minutes in the future, so a reporting job that falls weeks behind cannot simply backfill.
- Meter events are processed asynchronously, so usage summaries and upcoming invoices may lag recent events slightly.
// Report one aggregated window. A retry reuses the same identifier,
// so Stripe will not count this window twice.
await stripe.billing.meterEvents.create({
event_name: "api_requests",
payload: {
stripe_customer_id: customerId,
value: String(windowTotal),
},
identifier: `${tenantId}:api_requests:${windowStart.toISOString()}`,
timestamp: Math.floor(windowStart.getTime() / 1000),
});One important update for new builds: Stripe's comparison page now describes Metronome, a Stripe product, as the recommended starting point for all new usage-based integrations, while existing Billing Meters integrations remain fully supported and do not need to migrate. Metronome adds real-time usage tracking, prepaid credits, commitments and high-volume ingestion, and the same page sets out which features need it and where Metronome still has gaps (Connect, for example). Whichever engine you choose, the advice in this post still applies: keep your own raw record, send stable identifiers, and reconcile.
Reconcile as a routine job
Run a scheduled check that compares your aggregated usage for each customer and meter with what the provider recorded for the same period. Drift is not an exception to handle when a customer complains; it is a number you watch, so a discrepancy is caught before it ships on an invoice. If you can, run the check shortly before invoices finalize, when a correction is still cheap.
Proration, plan changes and credits
Metered pricing collides with the same lifecycle events as flat plans, with sharper edges. When a customer upgrades mid-cycle, changes their included allowance or adds seats, you must decide how usage already accrued is treated. Is the allowance prorated? Does usage before the upgrade bill at the old rate or the new one? Proration of the subscription part is the provider's job; proration of the usage allowance is a policy you define and document.
Credits and refunds need the same care. When a usage dispute is resolved in the customer's favour, issue a credit against the invoice rather than editing raw usage. Your usage table stays an honest record of what happened, and the money adjustment is visible on its own.
Preventing bill shock
Bill shock is the fastest way to lose a usage-based customer. Someone runs a heavy job, leaves a process looping or onboards a big team, and the next invoice is many times what they expected. Even when the charge is correct, the surprise damages trust and invites a chargeback or a cancellation.
The fix is visibility and control:
- A live usage meter in the product, with the current period's usage and a projected bill.
- Alerts as customers approach thresholds they choose. Stripe supports usage alerts on meters, or you can send your own from your usage table.
- Billing thresholds that invoice early once usage crosses an amount, which limits your credit exposure on very heavy users; Stripe documents threshold billing for this.
- Optional spend caps or soft limits that the customer sets, so a runaway job pauses or warns rather than generating a surprise.
A customer who can see the meter running rarely disputes the bill. Transparency is part of the billing system, not a nice extra. If you are designing that usage screen, our guide to designing B2B SaaS dashboards covers the patterns.
How much to build on day one
| Stage | Build | Defer |
|---|---|---|
| MVP | One value metric, idempotent usage table, daily aggregation, reporting with stable identifiers, a simple usage page | Credits, multiple meters, spend caps |
| Growing | Reconciliation job, threshold alerts, projected bill, tiered pricing | Prepaid credits, enterprise commitments |
| Mature | Real-time balances, prepaid credits, commitments, multiple meters, a metering engine such as Metronome |
A simple usage model in an MVP can start with basic metering and add reconciliation, alerts and caps as the customer base grows, as long as the counting layer is built honestly from the start. The expensive mistake is bolting metering onto a pipeline that was never designed to count anything precisely. If you are weighing how much to build up front, our MVP versus full build comparison helps frame it.
The short version
Usage-based and hybrid pricing can fit your product far better than a flat fee, but they raise the stakes on correctness. Choose a value metric customers understand. Build a metering pipeline that counts every event exactly once, attributes it correctly and respects period boundaries. Report aggregated usage with stable identifiers, reconcile before invoices finalize, and give customers a live meter and alerts so they are never ambushed by a bill.
If you are weighing usage-based pricing or wrestling with a metering setup whose numbers do not add up, our Stripe integration team does exactly this kind of work. Tell us how you want to charge and we will help you build billing that is right to the cent, every cycle.
FAQ · 05 questions
Frequently asked questions
What is usage-based billing?
Usage-based billing, also called metered billing or pay-as-you-go, charges customers according to how much of a product they consume in a billing period, such as API calls, gigabytes stored, messages sent or compute minutes. It is often combined with a base subscription fee in a hybrid model.
What is the difference between usage-based and hybrid pricing?
Pure usage-based pricing charges only for what was consumed, so the bill can be zero or very large. Hybrid pricing charges a fixed recurring fee that includes an allowance, then bills usage above that allowance. Hybrid gives you predictable base revenue and gives customers a more predictable bill.
How does Stripe handle usage-based billing?
Stripe's basic usage-based billing uses Billing Meters: you send meter events with a customer ID and a value, and Stripe aggregates them into the invoice at the end of the period. For new integrations, Stripe now recommends Metronome, a Stripe product built for real-time metering, credits, commitments and high-volume ingestion.
How do I stop customers from being double-charged for usage?
Give every usage event a stable, unique key when it is created and enforce uniqueness in your own database, so retries and redeliveries are ignored. When reporting to the billing provider, send a stable identifier or idempotency key for each report so a retried sync does not count the same usage twice.
How do I prevent bill shock with metered pricing?
Show customers their current usage and projected bill inside the product, send alerts as they approach thresholds they choose, and offer optional spend caps or soft limits. Clear pricing pages and an included allowance in a hybrid plan also make bills more predictable.