How to Build·14 min read

How to Implement Usage-Based Pricing in Your App

Usage-based pricing aligns your revenue with customer value. But implementing metering, billing pipelines, and real-time usage tracking is harder than flat subscriptions. Here is the engineering playbook.

N

Nate Laquis

Founder & CEO ·

Why Usage-Based Pricing Is Taking Over SaaS

OpenAI charges per token. Twilio charges per message. Vercel charges per function invocation. AWS charges per second of compute. Usage-based pricing has moved from infrastructure companies to mainstream SaaS, and the trend is accelerating.

The appeal is clear: customers pay for what they use, which lowers the barrier to entry and eliminates sticker shock. A startup paying $5/month for 1,000 API calls and an enterprise paying $50,000/month for 10 million calls are on the same pricing model, just at different scales. Revenue grows automatically as customers grow.

But the engineering complexity is real. Flat subscription billing requires tracking one thing: is the subscription active? Usage-based billing requires tracking every billable event in real-time, aggregating usage accurately, handling edge cases (what happens at exactly the billing boundary?), and giving customers visibility into their consumption. This guide covers the full technical implementation.

Usage-based pricing dashboard showing metered consumption and billing data

Choosing Your Pricing Model

Usage-based pricing comes in several flavors. Your choice affects both the billing architecture and customer experience.

Pay-As-You-Go

Customers pay only for what they consume, with no base fee. Examples: AWS Lambda ($0.0000002 per request), Twilio ($0.0079 per SMS). Pure pay-as-you-go has zero friction at signup but creates unpredictable revenue. Works best for infrastructure and API products where usage scales continuously.

Tiered Usage

Usage is grouped into tiers with different rates. First 1,000 API calls at $0.01 each, next 9,000 at $0.005, everything above 10,000 at $0.002. This incentivizes higher usage and rewards growth. Stripe, SendGrid, and Mailchimp use tiered models.

Hybrid (Base Plus Usage)

A flat monthly fee for a base allocation, plus per-unit charges for overages. Example: $99/month includes 10,000 API calls, then $0.005 per additional call. This gives you predictable base revenue while capturing upside from power users. Our recommendation for most SaaS products. It combines revenue predictability with usage alignment.

Credit-Based

Customers purchase credits upfront and consume them over time. Each action costs a certain number of credits. OpenAI's token model works this way. Credits create prepaid revenue (great for cash flow) and let you abstract complex pricing behind a simple unit.

The Metering Pipeline: Tracking Every Event

The core of usage-based billing is the metering pipeline: the system that records, aggregates, and reports every billable event. This pipeline must be accurate, durable, and fast.

Event Collection

Every billable action in your application emits a usage event. An API call, a message sent, a file processed, a compute second consumed. These events need to be captured reliably, even under high load.

Architecture options:

  • Synchronous logging: Record usage in your database within the API request. Simple but adds latency to every request. Acceptable for low-volume products (under 100K events/day).
  • Async queue: Emit usage events to a message queue (SQS, Kafka, RabbitMQ) and process them asynchronously. Better performance, eventual consistency. Our recommendation for most products.
  • Streaming pipeline: For high-volume products (millions of events/day), use a streaming pipeline with Kafka or Kinesis. Events are processed in real-time with exactly-once semantics.

Event Schema

Each usage event should include: customer ID, event type (api_call, message_sent, storage_gb), quantity (1 for single events, bytes for storage), timestamp (UTC), and idempotency key (to prevent double-counting). Store raw events immutably. Aggregate them separately. This lets you recalculate billing if you discover a metering bug.

Data pipeline architecture for real-time usage metering and event processing

Aggregation and Billing Calculation

Raw events must be aggregated into billable amounts. This sounds simple but edge cases abound.

Aggregation Windows

For monthly billing, aggregate events from the start of the billing period to the end. Sounds straightforward, but consider: what if the customer's billing cycle starts on the 15th? What if a usage event arrives late (queued during an outage and processed 2 hours later)? What if the customer is in a different timezone than your servers?

Use UTC timestamps everywhere and define billing periods as exact UTC time ranges. Accept late events within a grace window (1 to 24 hours after the billing period closes) and include them in the correct period. Events arriving after the grace window go into the next period or are handled through billing adjustments.

Stripe Meters

Stripe launched its Meters API specifically for usage-based billing. You report usage events to Stripe, and Stripe handles aggregation, tier calculation, and invoice generation. This eliminates the need to build your own aggregation pipeline. Report events via the API: stripe.billing.meters.create() and stripe.billing.meterEvents.create().

Stripe Meters supports sum, count, and max aggregation methods. For most products, sum (total API calls, total storage bytes) or count (number of events) is sufficient. Max is useful for "peak usage" billing (charge based on the highest concurrent users, not total).

Building Your Own

If Stripe Meters does not fit your pricing model, build an aggregation service that runs nightly (or on the billing date). Query raw events for the billing period, apply tier pricing logic, calculate the total amount, and create an invoice via Stripe's Invoicing API. Store the calculation details for auditability.

Customer-Facing Usage Dashboard

Customers on usage-based pricing need visibility into their consumption. Surprise bills destroy trust and cause churn. A usage dashboard is not a nice-to-have. It is essential.

What to Show

  • Current period usage: How much have they consumed so far this billing cycle?
  • Usage trend: A line chart showing daily consumption. This helps customers spot unexpected spikes.
  • Projected cost: Based on current usage trajectory, what will the invoice be at the end of the billing period?
  • Plan limits: If using a hybrid model, show included allocation vs current usage. "You have used 7,200 of your 10,000 included API calls."
  • Historical invoices: Past billing periods with detailed usage breakdowns.

Usage Alerts

Let customers set alerts at usage thresholds (50%, 80%, 100% of their expected budget). Send email and in-app notifications when thresholds are crossed. This prevents bill shock and gives customers control. Implement alerts as simple threshold checks in your aggregation pipeline. When the running total crosses a threshold, fire a notification event.

Real-Time vs Batch Updates

For most products, updating usage data every hour is sufficient. Real-time (sub-second) usage tracking adds significant infrastructure cost and is only necessary for products where overages are expensive (cloud compute, AI API calls). Start with hourly updates and decrease the interval only if customers request it.

Handling Edge Cases

Usage-based billing has more edge cases than flat subscriptions. Address these before launch.

Free Tier Overages

What happens when a free-tier user exceeds their allocation? Options: hard block (API returns 429 until next billing cycle), soft block (allow a small overage buffer then block), or auto-upgrade (start charging overage rates and notify the user). Hard blocks are simpler but risk losing engaged users. Auto-upgrade with clear notification is usually the best UX.

Mid-Cycle Plan Changes

If a customer switches from a $99/month plan (10K included calls) to a $199/month plan (50K included calls) on day 15, how do you handle it? Prorate the base fee and reset the usage counter? Prorate the base fee and carry over existing usage? Keep existing usage and give them the new allocation for the remainder? There is no universal right answer. Define your policy, document it in your terms of service, and implement it consistently.

Metering Failures

What if your metering pipeline goes down for 30 minutes? Events during that window are either lost (bad) or queued and processed later (good but creates a usage spike in reports). Design your pipeline with durability: events go to a persistent queue (SQS, Kafka) before processing, so nothing is lost during outages. Monitor metering pipeline health separately from your main application monitoring.

Billing Disputes

Store enough raw event data to answer customer questions like "why was I charged for 12,500 API calls when I only expected 10,000?" Being able to show detailed event logs with timestamps and request metadata resolves disputes quickly and maintains trust.

SaaS pricing analytics and usage-based billing optimization dashboard

Costs and Implementation Timeline

Here is what usage-based billing systems cost to build:

  • Basic metered billing with Stripe Meters (3 to 4 weeks, $12K to $20K): Event reporting to Stripe Meters, hybrid pricing (base plus usage), usage dashboard showing current consumption, threshold alerts, and Stripe invoicing for end-of-period charges.
  • Custom metering pipeline (5 to 8 weeks, $25K to $45K): Async event pipeline (SQS/Kafka), custom aggregation service, tiered pricing calculation, detailed usage analytics dashboard, prorated plan changes, and comprehensive audit trail.
  • Enterprise usage billing (8 to 14 weeks, $45K to $80K): Real-time metering, multiple billing metrics (API calls plus storage plus compute), custom enterprise contracts, prepaid credit system, revenue recognition integration, and advanced analytics with cost forecasting.

Tools That Reduce Development Time

  • Stripe Meters: Free with Stripe. Handles event aggregation and invoice generation. Reduces custom development by 2 to 4 weeks.
  • Metronome ($500 to $5,000/month): Purpose-built usage billing platform. Handles metering, rating, invoicing, and revenue recognition. Significant time savings for complex pricing models.
  • Orb ($500 to $3,000/month): Usage-based billing infrastructure with a focus on developer experience. Supports complex pricing models out of the box.
  • Amberflo ($500 to $2,000/month): Cloud metering and billing platform with real-time analytics.

Usage-based pricing is more complex to implement than flat subscriptions, but the revenue upside is significant. Companies with usage-based pricing grow 38% faster than those with flat subscriptions (OpenView's 2025 SaaS Benchmarks). The engineering investment pays for itself through better customer alignment and higher net revenue retention.

We build usage-based billing systems for SaaS companies transitioning from flat pricing. Book a free strategy call to discuss your pricing model and implementation plan.

Need help building this?

Our team has launched 50+ products for startups and ambitious brands. Let's talk about your project.

usage-based pricingmetered billingSaaS pricing modelconsumption billingStripe metering

Ready to build your product?

Book a free 15-minute strategy call. No pitch, just clarity on your next steps.

Get Started