API v2 is in beta (
2.0.0-beta). The subscription-based engine stays supported as Legacy (v1): Welcome to Lago. To compare the two models, read Contracts vs subscriptions.How billing works
The sections below explain how usage, pricing, invoices and payments fit together. Fixed Products do not need usage events.1. Record usage
An event records your customer’s usage. In this example, your application sends one event for each API call. Theexternal_contract_id field identifies the customer’s Contract.
Events can include properties such as region. You can use these properties to price groups of usage differently.
2. Measure usage
A billable metric defines how Lago measures usage from events. In this example, the Count aggregation (count_agg) counts API call events.
With 2,000 matching events, the billable quantity is 2,000 calls. The metric determines the quantity; the Rate determines the price.
3. Define pricing
Pricing connects what you sell to the terms each customer receives. Each object has one role.
A Product can belong to a Product category or stand alone. A category organizes Products. It never sets a price.
The diagram shows how the objects relate. Arrows describe relationships, not setup order.
Each Rate Card targets either a Product or one of its filters. It holds the shared billing settings and the Rates that define pricing over time. The
api_calls_usd Rate Card targets api_calls_product. Its Rate sets the price at $0.01 per call. A later Rate can introduce a new price from a specified date.
The Plan brings the offer together. The Contract connects those terms to the customer. In this example, each invoice line relates to a Product, a Rate Card, a Rate and a quantity.
4. Calculate invoice amounts
Lago calculates fees from the customer’s Contract and the billed quantities. The Rate’s billing interval and the Rate Card’s billing timing decide when fees are invoiced. For one full monthly period, with one fixed unit, 2,000 API calls, and no proration, discounts, credits or taxes:
To check an invoice line, compare its Product, Rate, quantity and billing period with the Contract’s billing terms.
5. Collect and record payments
An invoice records what your customer owes. You can collect payments through a payment provider or record payments received outside Lago. A finalized invoice does not mean the customer has paid.Where to go next
Where both options are available, task guides include Dashboard and API instructions.
Your first invoice
Create a Contract and invoice a $100 monthly fee plus $0.01 per API call.
Contracts vs subscriptions
Compare the contract-based and subscription-based billing models.
Lago Cloud
Use the hosted Lago service.
API reference
Base URLs, authentication, pagination and errors for
/api/v2.