Skip to main content
SubscriptionFlow Docs
Customization

Show Customers Their Usage Inside Your App

Updated

If you bill for usage, your customers will want to see how much they've used. You can show them inside your own product in two ways.

Option 1: Embed the customer portal

The SubscriptionFlow customer portal has a Usages page that lists the customer's usage records. Embed the whole portal in your app with SubscriptionFlow.mountPortal(), and customers can open Usages from the portal menu without leaving your app.

See Embedded In-App Widgets for the setup: the header script, mountPortal, and the ready and error events.

This is the quickest option and needs no extra development, but customers see the portal's own layout.

Option 2: Build your own usage view with the API

To show usage in your own design, such as a chart on your dashboard, read it from the usage API and draw it yourself.

For AI usage billing (tokens, API calls and other metered events), use:

GET https://<your-subscriptionflow-domain>/api/meter/v1/usage

Useful parameters:

Parameter What it does
meter Limit to one meter, for example llm.tokens
group_by How to group the totals, for example by dimension (the default) such as model
from, to The period; defaults to the last 30 days
subscription_id Limit to one subscription
customer_id Which customer (only with a server key; a customer key always returns its own customer)

Use a customer key in your app so a customer can only ever read their own usage. Keep server keys on your server. A related endpoint, GET /api/meter/v1/balance, returns a prepaid customer's remaining credit.

There's no ready-made usage chart widget to embed on its own. Use the portal (option 1) or build your view from the API (option 2).

Was this article helpful?0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.