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 we encounter a delay when pre-paid credits burn down. This makes real-time credit tracking almost impossible, especially for high-volume APIs. However, Moesif can update the API users’ balance in real time since Moesif receives traffic in near real time. Moesif can also calculate the cost of each API call based on a Billing Meter and automatically decrease the corresponding amount from the users’ remaining balance.

This allows you to still use platforms like Stripe or Zuora to process payments, do financial reporting, and so on. At the same time, you can leverage Moesif to allow or disallow access to an API in real time based on a user’s actual available balance. You to get the best of both worlds:

  • Handle the financial aspects of API monetization on your favorite billing platform
  • Enable consistent and dependable pre-paid API monetization through Moesif’s Credit Tracking feature.

Implementation Notes

Thee balance ledger in Moesif differs from that of the billing provider. Therefore, if a user has topped up their account balance in a platform like Stripe, it doesn’t automatically updates in Moesif. This allows the maximum flexibility and 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.

Updated: