Usage-Based Subscriptions
In this tutorial, we’ll dive into the core concepts of usage-based billing, explore real-life examples of usage-based pricing models, and guide you through the steps to start charging customers based on their usage with Lemon Squeezy.
Usage-based billing core concepts
Usage-based billing charges customers based on what they use rather than what they plan to use. Unlike standard subscriptions where customers are billed up-front, usage-based subscriptions bill customers in arrears, based on their actual usage during the billing cycle.
In Lemon Squeezy, usage-based billing is an optional setting you can apply to individual products and variants.
When the “Usage is metered?” toggle is active, the following happens:
- Customers are not charged at checkout when starting a subscription.
- Your application needs to sends Lemon Squeezy up-to-date usage information during the subscription period.
- Customers are billed in arrears based on the reported usage.
You can choose how usage records are utilized for billing, such as “Sum of usage during period” or “Most recent usage,” giving you control over how usage is applied to customer payments.
In addition to flat-fee pricing, we offer tiered pricing models: volume and graduated, allowing you to create detailed pricing structures.
Examples of usage-based billing
Usage-based billing can apply to various unit-based subscriptions:
Company A (Volume pricing model)
- Sells software access per seat via license keys.
- Prices change with the number of seats (volume pricing model):
- up to 4 seats at $9/month/seat
- up to 10 seats at $8/month/seat
- up to 20 seats at $6/month/seat.
Company B (Package pricing model)
- Operates an API platform
- Charges €9 per package of 1,000 API call credits (package pricing model).
Company C (Graduated pricing model)
Runs a database platform, charging by the number of queries:
- $0.03 per query for the first 1,000 queries
- $0.02 per query for the next 1,000 queries
- $0.01 for all subsequent queries (graduated pricing model)
These companies periodically send usage data to Lemon Squeezy, so the invoices reflects the number of actual units used.
Adding usage-based billing to your app
Enable usage-based billing on products
Create a product and toggle on the “Usage is metered?” option in the product settings.
Choose how usage will be calculated, e.g., “Maximum usage during period” or “Sum of usage during period.”
Set up webhooks
Set up webhooks to automatically receive data when subscriptions are created or updated. Webhooks can be created in your dashboard or via API. For a full implementation, refer to our Developer Guide.
You will also need certain data stored locally in your application, like subscription item IDs needed to report usage. Read our suggested list of data to store locally.
Send customers to checkout
Customers purchase your products via checkout URLs like they would normally do. With usage-based billing enabled, no charge is made at checkout, but payment details are captured for future renewals.
Report usage to Lemon Squeezy
Send usage data to Lemon Squeezy as frequently as needed.
- For example, if you’re selling seats, you can report usage to Lemon Squeezy when a new team member is added to an account.
- Or, if you’re selling API credits, you can report to Lemon Squeezy immediately after each credit is used, or daily with an update of customers’ total usage for the billing period.
To make usage reports use our usage record endpoint:
In API calls you need to report usage either as an incremental change or to replace any previous usage total. This is based on the usage aggregation you chose when enabling usage-based billing on your product (Step 1).
- Using
"action": "increment"
will add the providedquantity
value to any existing quantity for the current billing period. Use this with “Sum of usage during period”. - Using
"action": "set"
will replace any existing usage with the providedquantity
value. Use this with “Most recent usage during a period” and “Most recent usage”.
In the example above, we are reporting to Lemon Squeezy that the user has used an additional 23 units of units.
Querying usage
For information on how to query usage refer to the Usage-based billing developer guide.