Using the /entitled Endpoint
Learn how to check feature access and record usage with the Autumn API
The /entitled
endpoint allows you to check if a customer has access to a specific feature. This endpoint is versatile and can be used for different types of features within your product.
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:
The response will include an allowed
property indicating whether the customer has access to the feature.
You can do this from the client side, eg when a user clicks a button to use a feature, or from the server side when running that feature.
Checking Metered Features
For features with usage limits, the response includes both access permission and current usage limits. You can
Recording Usage with Event Data
You can check entitlement and record usage in a single API call using the event_data
parameter
We recommend doing these as separate steps in your application logic, to only record usage if the event is successful.
Checking Required Quantity in Advance
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 entitlement.
Creating New Customers
If the customer_id
you provide doesn’t exist yet, Autumn will automatically create a new customer:
The customer_data
object lets you provide additional properties for the new customer.