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.
Make sure you have some metered features created before creating a credit system.
value
field in the track
route) should be worth.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.
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.
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.
audio-transcription-minute
costs 7 cents, our credit amount will be 7.See the credits pricing guide for a more detailed example of setting up a monetary credits system