Syncing All Entitlements
The simplest way to check entitlements is by using Autumn’s /entitled endpoint, to check if a user has access to a specific feature whenever it’s requested.
However, you may also use the /customer endpoint, which will return all of a user’s active entitlements at once. This is useful if you want to:
- Display a list of entitlements or usage balances to a user
- Minimize the number of API calls you make
- Sync up Autumn with your internal access control system
Overview
To sync up your application with Autumn, here are the steps you can follow:
Fetch a customer's entitlements on login
Call the /customer
endpoint to get all active entitlements
Sync entitlements with application
Update your application logic to use the entitlements you fetched
Send usage events to Autumn
Track usage for metered features by sending events
Refresh customer entitlements
Update entitlements after recording new usage
Fetching Customer Entitlements from Autumn
When a user logs in, retrieve their current entitlements using the /customer endpoint. You should use the customer_id
of the user that you set when you created the customer (typically your internal user ID).
The response will include an array of entitlements:
Syncing Autumn Entitlements with your application
When a user logs in, sync their entitlements to ensure your application has the most up-to-date information. You’ll need to create a mapping function to do this.
Sending Usage Events for Metered Features
For metered features, you’ll need to send usage events to Autumn whenever a user consumes a unit of that feature:
Refreshing Entitlements After Usage
After sending a usage event, refresh the customer’s entitlements to reflect the updated balance. Here’s the full function covering the steps above: