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:

  1. From your Moesif Web Portal, go to Billing Meters.
  2. Select Edit Billing Provider.
  3. Select Stripe.
  4. 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:

  1. From your Moesif Web Portal, go to Companies.
  2. Select Companies and then select Company Cohorts in the navigation menu.
  3. Select + Cohort in the Companies screen that appears.
  4. Enter a name for the cohort—for example, Companies with Overage.
  5. To only include companies that possesses an active subscription, specify the filter Subscriptions.status.is.active.
  6. For the event filters, select Event Type.is.API Call.
  7. Enter 10 as the event threshold value and the At Least modifier to define the overage threshold.
  8. Select Create Cohort.

Creating a company cohort for overage customers

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:

Example pricing in Stripe to implement overage charge

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:

Including the cohort for overage customers in the billing meter

Next Steps

Updated: