Checking Access
Learn how to check feature access with the entitled
route
When you create a product in Autumn, you define what features your customers on that product get access to.
The entitled
method returns the allowed
property to check if a customer should have access to a feature, so you can block access or prompt them to upgrade.
Checking Metered Features
Before your customer uses a feature, you can check if the customer is allowed to use it and their current usage.
Example Use Case:
Let’s imagine you have a free product that allows 100 AI messages per month. Before your customer sends an AI message, you can check if they have any remaining messages.
If they still have messages remaining, they’ll be allowed to send an AI message. You can then record the usage event so Autumn can keep track of the balance.
Even if your product doesn’t have usage limits (ie your product is purely usage-based), you can still use the above method to prevent excessive usage if a customer’s payment fails.
If the product status is past_due
, by default, Autumn will block access to the feature.
Checking for a Required Quantity
If you know the quantity a user will consume in advance, you can specify it with the required_quantity
parameter. This means you can prevent a user from starting a process that would consume more than their allowance.
By default, required_quantity
is 1, so not passing this parameter will return allowed: true
as long as the customer has a feature balance of 1 or more.
Checking Feature Access and Recording Usage together
In a typical workflow, you’ll want to check if a customer has access to a feature and then record the usage as separate steps.
However, you can check entitlement and record usage in a single API call using the send_event
field. The usage value will be the required_quantity
parameter.
We recommend doing these as separate steps in your application logic, so usage is only counted if the event is successful.
Alternatively, you can “refund” usage with a negative usage value
if the event fails.
Checking Boolean Features
For simple on/off features, use the endpoint to determine if a customer has access.
You can do this on the client side on page load, using a useEffect
function: