Lago is an open-source billing API that helps engineers implement faster their billing engines. More and more companies, such as Notion or Slack, are implementing a complex per-seat fair pricing model.
You only make your customers pay for active members and what they really use. Members added or removed during a billing period are pro-rated based on the number of days used.
The total number of units to be paid at the end of a period depends on the actual number of days really used by the members.
Lago has developed a special feature to implement faster than ever this fair pricing policy, called persistent billable metrics. Let’s try to replicate Slack’s pricing with Lago!
You can find the main Lago repository here.
Before we get started, you need to:
💡 We use basic CURL API calls for this demo, but Lago also provides API clients in order to make the implementation process easier.
Start running Lago on your own environment. You will have access to the Lago API and Lago UI (frontend admin panel to perform no-code tasks).
You can now open your browser and go to http://localhost to connect to the application. Lago's API is exposed at http://localhost:3000.
If needed, you can override your environment variables (learn more).
As our user seats are billed month over month unless you remove a user, we are going to use the persistent billable metrics, with a recurring_count aggregation. This means that you won’t have to send an event each month for a user who was added a few months ago and who’s still using your product. Lago will keep it in your “billing memory” until you remove this user.
It’s useful to emphasize several points here:
To replicate Slack’s pricing, we can focus on building the Pro plan, starting at €8.25 per active user if you pay monthly.
Let’s break down the code written above:
First, let’s create a customer using the API. As Airbnb is a power customer of Slack, we can take this company as an example.
Then, we assign the Pro plan to this Airbnb customer.
About the subscription request:
Each user seat is priced €8.25 for a full month. Let’s send events to get a better understanding of this logic. Lago allows you to send persistent events:
Use the operation_type called add to add a user seat to Lago’s billing system.
As the user seat is added in the middle of the month, Lago automatically creates a pro-rated charge based on the number of days used.
In this example, one user was added for the full month and the other only for half the month.
A user who’s removed during a period is also charged with a pro-rated amount based on the number of days used. Use the operation_type set to remove to remove a user seat during a period.
Let’s take a closer look at the PDF invoice created by Lago: it shows the seat history for the billing period under consideration. This detailed invoice provides the information necessary for your customers to understand the billing method.
This is how Lago can help you implement a per-seat billing system in just a few hours (not months). It’s easy to build but also easy to maintain.