Apply API Usage Overage Fees Using Stripe and Moesif
Overview
In this guide, you’ll learn how to implement overage usage fees with Stripe and Moesif. This allows you to charge customers who’ve exceeded their allocated usage limits in the plan they’ve subscribed to.
Objectives
- Create a company cohort to define overage customers.
- Configure your billing meter that defines how to meter and charge overage users.
Before You Start
Make sure you have active accounts in the following platforms:
Set up Stripe
This tutorial uses Stripe as the billing provider. Moesif tracks product usage, meters the usage according to a billing meter, and sends the details to Stripe. Stripe then charges the customer.
To configure Stripe for this tutorial, follow these steps:
- From your Moesif Web Portal, go to Billing Meters.
- Select Edit Billing Provider.
- Select Stripe.
-
Follow the instructions in the dialog. For more information, see the following sections of our Stripe integration documentation:
Create Overage Customers Cohort
In Moesif, cohorts define a dynamic list of users that match specific criteria that you define. In this case, we create a cohort that defines the criteria for overage customers. When a customer exceeds their usage limits, Moesif will automatically add them to this cohort.
For this tutorial, the cohort has the following properties:
- It only includes companies that possesses an active subscription.
- It only counts API Call event types.
- It considers a customer overage if they exceed more than 10 API calls in the subscription’s current monthly period.
Follow these steps to create the cohort:
- From your Moesif Web Portal, go to Companies.
- Select Companies and then select Company Cohorts in the navigation menu.
- Select + Cohort in the Companies screen that appears.
- Enter a name for the cohort—for example,
Companies with Overage
. - To only include companies that possesses an active subscription, specify the
filter
Subscriptions.status.is.active
. - For the event filters, select
Event Type.is.API Call
. - Enter
10
as the event threshold value and theAt Least
modifier to define the overage threshold. - Select Create Cohort.
Configure Overage Charge
To model overage pricing, we create a volume pricing model for the plan. The first tier charges customers a flat recurring amount up to a specific number of units. This can represent the monthly subscription price you have for your product. The next tier charges customers on a per-unit basis once customers exceed the usage limit in the first tier. Here’s how it might look in Stripe:
Specify Overage Customers Cohort in Billing Meter
Lastly, include the cohort in your billing meter so your billing meter accurately tracks when a customer reaches the overage threshold.
To include the cohort, select it from the Performed By list: