Entities
Learn how to use feature entities to track balances per separate entity, such as a user or a workspace
Feature entities are used to keep track of sub-balances for a feauture. For example, you may have a product that allows 500 credits per user per month.
To start, add the feature entity as a product item in the Autumn dashboard.
- Go to the Products Page and click into the product you want to add a feature entity to.
- Click the ”+ Feature” button.
- Select the feature to track (eg,
credits
) - Click the elipsis on the right of the feature selector and click “Add per Feature Entity”
- Select the entity you want to add (eg, per
user_id
) - Define any included usage (eg, 500 credits per user) and add the product item.
Managing entities via the API
You can manage feature entities via the entities
route. This can be used to create, update and delete entities, such as when a seat is added or removed.
When you create a feature entity, a usage event will automatically be sent that increments the count of the number of entities (eg seats) being used.
This means if you create 2 entities for “seats”, your usage of “seats” will be 2.
Manging entity balances
Just like with normal features, you can check feature access and send usage events for entity.
Check feature access
Send usage event
Top-level vs entity-level balances
Top-level balances are the total balance for the feature across all entities. Entity-level balances are the balance for a specific entity. You can check access and send usage events either at the top-level or entity-level.
Example use case
You have a product that allows 500 credits per user per month. However, the credits are shared across all users in the account.
You can create a feature entity for “seats” and then check access and send usage events at the top-level.
To use top-level balances, just omit the entity_id
from your entitled request.
And similarly for usage events.
This will increment the usage counter for the top-level balance, and also deduct from the first-created entity so that the sum of the the entity balances is always the same as the top-level balance.