Creating a credit system
Make sure you have some metered features created before creating a credit
system.
- Navigate to the products page
- Click the “Features” tab
- Click ”+ Credit System”
- Add each metered feature you want to affect the credit system.
- For each feature, define how many credits each unit of usage (ie, the
value
field in thetrack
route) should be worth. - Click “Create”
ExampleIf each
audio-transcription-minute
is worth 3 credits, then using 6 minutes of audio transcription will cost 18 credits.Using credits via the API
When implementing a credit system into your application, you should interact with the underlying features (not the credit system itself).audio-transcription-minutes
feature.
When checking for feature access, if a feature is not defined in the credit
system (and not in any other product items separately), it will return
allowed: false
audio-transcription-minute
costs 3 credits, since we sent a usage event for 10 minutes (value: 10
), it will cost us 30 credits. We started with 10000 credits and our remaining balance will be 9970 credits.
Monetary credits
You may want your credit system to represent a monetary value: eg, $10 of credits. To implement this, you typically want to treat each credit as 1 cent.- When creating your credit system, make sure that you define credit amounts in the per-cent cost
Eg: if eachaudio-transcription-minute
costs 7 cents, our credit amount will be 7. - Set any included usage of credits in cents
Eg, if customers get 5 USD credits for free, they should have an included usage of 500. - Set the cost of each credit to 1 cent (0.01) when handling prices