Credits
Learn how to create a credit system in Autumn
Credit systems allow you to track and limit the usage of multiple different features from a shared balance. This can simplift billing when you have many different usage-based features, and they all cost different amounts.
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 the events route) should be worth. - Click “Create”
Example
If each audio-transcription-minute
is worth 3 credits, then using 6 minutes of audio transcription will cost 18 credits.
Now you can add these credits as a product item within a product. Such as 50 credits per month or $1 per credit.
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).
The response will contain the ID of the credit system you defined.
In this case, we have a balance of 10,000 credits remaining, so we’re allowed to use our 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
Now we can send a usage event:
In this case, if each 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
See the credits pricing guide for a more detailed example of setting up a monetary credits system