Blog
/
Guides

Event-Based Billing: How It Works and How to Build It

Build an event-based billing system with reliable events, metering, pricing, customer attribution, and invoicing for SaaS, APIs, and AI products.

Sara NelissenSara Nelissen
Written by
Sara Nelissen
Last updated
September 22, 2026
read time
9
minutes
Event-Based Billing: How It Works and How to Build It

Table of contents

Event-based billing looks clean in a pricing document. A customer does something, you record it, and the bill reflects the usage. It’s production traffic that adds the harder parts. Events retry, arrive late, carry the wrong account ID, or need different treatment under an enterprise contract.

This guide shows how event-based billing works from event capture to invoicing, how to build it reliably, and where runtime usage controls fit.

What is event-based billing?

Event-based billing is a billing method that uses recorded product actions as the input for calculating customer charges.

A billable event could represent an API request, transaction, message, compute job, document processed, workflow completed, or another measurable action.

The event usually records usage first. A meter then decides how that activity counts, and a rating layer applies the customer’s pricing terms.

Event-based billing overlaps with several related concepts. Usage-based billing describes pricing that changes with consumption, while metered billing focuses on measuring that consumption.

A product can use all of these ideas together. API requests become events, a meter counts them, and the customer pays according to the rate attached to that usage.

How does event-based billing work?

Event-based billing moves product activity through a billing pipeline until the usage becomes a financial charge. A typical flow looks like this:

Product action → event → ingestion → metering → rating → invoice

1. The product creates an event

The application records a defined action when it occurs. A messaging product might send an event like this:

{

  "event_id": "evt_7421",

  "customer_id": "cus_104",

  "event_type": "sms_sent",

  "quantity": 1,

  "timestamp": "2026-08-31T13:42:19Z"

}

The payload captures what happened and who produced the usage. The application does not need to calculate the customer’s final price at this stage.

Keeping commercial logic downstream lets the same sms_sent event work across different plans, volume bands, and enterprise contracts.

2. Ingestion validates and stores the event

The event now enters the metering or billing infrastructure.

Real traffic brings retries, malformed payloads, temporary outages, and bursts of events. The ingestion layer needs predictable handling for each case because event accuracy eventually becomes invoice accuracy.

A stable event ID is especially useful. If a producer retries delivery after a timeout, the system can identify the repeated event and avoid counting the same action twice.

3. Metering turns events into quantities

Raw events do not always equal the final billing unit.

A compute product could record every completed job and use those events to measure:

  • Job count
  • Total processing time
  • Premium jobs
  • Unique active customers

Usage metering defines how those source events become measurable quantities.

One event stream can support several meters, which gives you room to change pricing without rebuilding product instrumentation every time.

4. Rating applies the customer’s pricing terms

The rating layer takes measured usage and applies the relevant commercial rules.

Those can include per-unit rates, included allowances, pricing tiers, commitments, credits, overage charges, and customer-specific rates.

A customer might generate 120,000 API requests on a plan that includes 100,000. The meter records the full usage, while the rating layer prices the 20,000 requests above the allowance.

That boundary keeps rate cards and contract logic out of application services.

5. Billing creates the financial record

Rated usage eventually reaches the billing system, where it can become an invoice line item.

The wider billing software architecture may also own adjustments, tax, payments, refunds, and financial records.

Traceability should survive the full path. A disputed charge is much easier to investigate when you can follow the invoice line item back through its meter to the events that created it.

What makes a good billing event?

A good billing event contains enough context to identify, measure, and trace the usage consistently.

Most event contracts need a small set of fields.

  • Event ID gives the usage record a stable identity
  • Customer ID connects the activity to a commercial account
  • Event type defines the product action
  • Quantity records how much usage occurred
  • Timestamp records when it happened
  • Properties preserve dimensions needed for pricing or reporting
  • Schema version tells downstream systems how to interpret the payload

Field definitions deserve as much attention as field names. quantity: 50 is useless if one producer means 50 requests and another means 50 megabytes.

Treat the schema as a long-lived contract. Once invoices and meters depend on a field, changing its meaning affects historical usage as well as new events.

Idempotency belongs in the event design

Billing infrastructure should assume delivery can happen more than once.

A producer may successfully send an event, lose the response, and retry. A stable event ID or idempotency key lets the receiver recognize that both deliveries belong to the same product action.

AWS Marketplace applies deduplication rules to metering records and documents retry handling for failed submissions. Keep the same billing identity for a product action across every retry.

Keep event time separate from ingestion time

Usage can reach the billing pipeline after it occurs.

A job completed near the end of a billing period may sit in a queue and arrive after the next period has started. Keeping event time and ingestion time separate gives you enough information to handle that delay consistently.

Your billing policy should define how long late events are accepted, how closed periods are treated, and where corrections appear.

How do events become billable metrics?

Billable metrics define how raw events count toward the customer’s usage.

A data product might emit four query_executed events. Those same records could feed a meter for four queries, total compute seconds, unique users, or usage grouped by processing class.

The product event stays stable while the commercial measurement changes.

That separation is useful when pricing evolves. You may be able to introduce a new meter or pricing plan while leaving the underlying event producer untouched.

It also prevents product code from becoming tightly coupled to every commercial experiment you run.

Common event-based billing models

Event data can support several pricing structures.

Model Example
Per event $0.02 per message
Tiered Rate changes by band
Hybrid Base fee + usage
Credits Events consume balance
Commit + overage Allowance + excess
  • Per-event pricing works well when each qualifying action has a similar value or cost. A communications product could charge the same amount for every message sent.
  • Tiered pricing changes the rate as usage crosses defined bands. Accurate aggregation becomes important because the customer’s total usage determines where each unit lands.
  • Hybrid pricing combines a recurring fee with event-driven usage. A plan could include a monthly allowance and charge for additional events after that amount is consumed.
  • Credit-based pricing converts events into balance consumption. Different workloads can burn different numbers of credits while the product keeps reporting the underlying activity.

Consumption-based billing covers these broader usage models and how they apply to variable-cost products.

Where event-based billing works best

Event-based billing fits products where usage can be measured consistently and tied to a meaningful customer action or resource.

  • APIs can record requests, tokens, records processed, or compute consumed. More complex implementations also need reliable customer attribution and contract handling, which the usage-based API billing guide covers in more depth.
  • Communications products already produce natural usage records through messages, emails, calls, and processing minutes.
  • Infrastructure products can emit compute jobs, queries, storage changes, and data-transfer events, often with a quantity attached.
  • Fintech products can use transactions, payouts, transfers, and other financial actions as the usage source for pricing.
  • AI products may need more thought because one customer action can create several internal workloads. An agent request could trigger model calls, retrieval, tool execution, and an external API. Engineering may track all of them while the customer sees a simpler metric such as credits, agent actions, or completed workflows.

The useful pattern across all five is the same. Keep granular product activity available without forcing every internal operation onto the customer’s invoice.

How to implement event-based billing

A reliable implementation starts with a clear billable action, then builds identity, event contracts, ingestion, metering, and correction rules around it.

1. Choose the billable action

Start with the unit the customer sees and understands. A document-processing product might track database reads, storage, and compute internally while billing for documents, pages, or processing units.

The strongest billing units stay useful even as the underlying implementation changes.

2. Preserve customer identity

Usage often moves through several layers before it reaches the account that pays for it.

Agent → workspace → department → organization

The agent may create the event, the workspace may hold the allowance, and the organization may receive the invoice. Keeping that hierarchy intact gives you clearer attribution, reporting, allocation, and usage controls.

3. Standardize the event contract

Every producer should follow the same rules for the data it sends.

A shared contract should define:

  • Event ID
  • Customer ID
  • Event type
  • Quantity and unit
  • Event timestamp
  • Relevant properties
  • Schema version

Document what each field means as well. A stable schema gives downstream meters a dependable input and prevents two services from interpreting the same field differently.

4. Make ingestion retry-safe

Billing events will be retried, delayed, rejected, and occasionally delivered more than once. Design for that behavior from the beginning.

Generate one stable event ID at the source and reuse it across delivery attempts. The ingestion layer can then recognize repeated records without creating additional usage.

Monitoring belongs here too. Duplicate rates, rejected payloads, and ingestion lag can expose pipeline problems before they affect an invoice.

5. Keep metering and pricing separate

The pipeline should preserve a clean division of responsibility.

  • Events record product activity.
  • Meters calculate usable quantities.
  • Rating applies commercial rules.

That separation lets one stream of product events support several plans, customer contracts, and pricing models. Application services can keep reporting the same activity while the commercial layer evolves around it.

6. Plan for corrections before billing goes live

Late events and incorrect records are normal cases, which makes correction behavior part of the initial design.

A useful audit trail preserves the original usage record, the correction, and the resulting financial change. Backfills, attribution fixes, and quantity adjustments should remain traceable after an invoice changes.

Financial ownership should be explicit too. Invoice generation, refunds, taxes, contract changes, and adjustments each need one authoritative system. Clear boundaries keep the same billing rule from drifting across several services.

Where event-based billing breaks

Event-based billing breaks when usage data becomes inaccurate, delayed, or inconsistent across the pipeline.

  • Duplicate events inflate usage. Stable event IDs keep retries from creating extra charges.
  • Dropped events miss billable activity. Durable delivery and reconciliation catch gaps.
  • Late events cross billing periods. Set a clear acceptance window and correction policy.
  • Bad attribution charges the wrong account. Preserve stable customer and tenant identities.
  • Schema drift changes event meaning. Version fields and units when contracts change.

A simple in-house pipeline can handle a few event types well. It gets harder once more services emit usage, contracts add overrides, or historical events need reprocessing.

How runtime enforcement fits into event-based billing

Event-based billing records and prices usage after it happens, while runtime enforcement uses current usage state to decide whether the next action can run.

An API may need to block request 100,001 once a customer reaches a 100,000-call limit. An AI product may need to check a credit balance before another model call or tool execution creates cost.

That decision relies on entitlements, usage limits, or credit state in the request path. Billing can keep recording consumption while runtime enforcement controls what the product allows next.

Where Stigg fits into event-based billing

Stigg sits in the part of the stack where usage starts affecting what the product can do next: the runtime layer above your billing system.

Stigg is the usage runtime for AI products, enforcing entitlements, credits, usage limits, and spend rules synchronously in the request path, and integrates with Stripe, Zuora, Chargebee, or custom billing without a rip-and-replace.

For event-driven products, Stigg gives you:

  • Usage metering that attributes consumption to the right customer, product, feature, or agent
  • Entitlements that resolve current feature access and usage allowances
  • AI credits with ledger-backed grants, deductions, expiry, and adjustments
  • Synchronous enforcement before another AI workload runs
  • Complex tenancy across accounts, departments, users, and agents
  • BYOC with the Sidecar running as a Docker container inside your VPC, with data-residency guarantees for regulated workloads
  • Modular adoption of metering, entitlements, or the credits engine independently

The Sidecar runs as a Docker container alongside your application, caching entitlement data in Redis so access decisions resolve from local cache even if the Stigg API is unreachable.

Cache hits resolve instantly, and on a cache miss, the Sidecar fetches from Stigg's Edge API in around 100ms, with a configurable timeout to prevent upstream latency from cascading into your application.

This keeps usage checks reliable under high-volume traffic without scattering credit and limit logic across your codebase.

Startups can begin with a single SDK integration or one runtime component, adopting metering, credits, or entitlements independently. The Stigg docs show how each piece connects to the wider usage runtime.

FAQs

1. What is event-based billing?

Event-based billing uses product events to calculate customer charges. Common events include API calls, transactions, messages, compute jobs, and completed workflows. Those events are then metered, priced, and passed to the billing system.

2. How does event-based billing work?

Event-based billing captures product activity, turns events into usage metrics, applies pricing rules, and sends the rated usage to billing. A typical pipeline includes event ingestion, validation, metering, rating, and invoicing.

3. Is event-based billing the same as usage-based billing?

The main difference between event-based billing and usage-based billing is what each term describes.

Event-based billing focuses on capturing activity as events, while usage-based billing describes pricing that changes with customer consumption. Many usage-based products use event-based infrastructure underneath.

4. Can event-based billing work with subscriptions?

Yes. Event-based billing can support hybrid pricing, where a recurring subscription includes a usage allowance and additional events are charged once that allowance is used. This is common when you want a predictable base fee with variable charges on top.

5. How do you prevent duplicate billing events?

To prevent duplicate billing events, use a stable event ID or idempotency key for each product action.

Reusing that identifier across retries lets the ingestion layer recognize duplicates and count the usage once. This prevents temporary network failures from turning into inflated usage or incorrect invoices.

Latest news.

One email per month.
From engineers, for engineers.

Thank you! Your submission has been received.
Oops! Something went wrong while submitting the form.