Introduction to Usage Credit Tracking & Consumption

As part of Moesif’s API Monetization features, Moesif can internally track credit balances and usages.

Many billing platforms have hard limits on how often usage can be reported, meaning that there is a delay in pre-paid credits being burnt down. Because of this, real-time credit tracking is almost impossible to do, especially for high-volume APIs. With Moesif, the API users’ balance is updated in real-time since Moesif receives traffic in near real-time and can calculate the cost of each API call performed (based on a Billing Meter) and automatically decrease the spend from the users’ remaining balance.

This means that the billing provider, such as Stripe or Zuora, can still be used to process payments, do financial reporting, etc. but Moesif can allow/disallow access to an API in real-time based on their actual available balance. Allowing you to get the best of both worlds: handle the financial aspects of API monetization on your favorite billing platform while being able to enable consistent and dependable pre-paid API monetization through Moesif’s Credit Tracking feature.

Implementation Notes

When using Moesif’s credit tracking feature, it’s important to realize that the balance ledger in Moesif is separate from that of the billing provider. This means that if a user has topped up their account balance in a platform like Stripe, it will not automatically be updated in Moesif. This is done for maximum flexibility and to allow users to customize their monetization approach as much as possible.

There are ways to automate this process so that top-up amounts added within the billing provider will be automatically added to the Moesif balance. This can be done via API and the exact mechanisms are covered on the Managing Credits docs page. To guide users towards a few ways they can do this, we have created an example with Stripe that shows users three distinct ways they can automate this process. These include:

  • Using Stripe’s Webhook functionality to intercept a payment_intent.succeeded event and calling the Moesif Credit Tracking API to add the top-up balance on the Moesif side.
  • Creating a /top-up endpoint that takes a Stripe Customer ID and a top-up amount. The endpoint will create a payment intent, process it on the Stripe side, and then add this balance to Moesif.
  • A final example showing how to use an API for the top-up in Stripe (using a payment intent) and a webhook to asynchronously add the credits to Moesif when the payment intent has succeeded.

To use the Credit Tracking functionality, simply go to the Company Profile page for the company you would like to manage or report on. You will then see that the company’s profile will allow you to manage their credits:

Consumption fields in the Moesif UI

And it will also allow you to report on their consumption.

Subscription Balance Report for Company

For more info on managing and reporting on credit consumption, check out the docs pages on both subjects.