check method returns the allowed field in real-time to check if a customer should have access to a feature. You can use this to block access and prompt an upsell.
The allowed field
The allowed field will return true for a given feature if:
- The customer has an active plan with this feature
- The customer has an active plan with a
credit_systemthat grants this feature - The plan feature is included or prepaid, and the current balance is greater than the
required_balanceparameter - The plan feature is usage-based, and the user has not exceeded their max spend limit
- The plan feature is unlimited or a boolean feature
allowed field as necessary.
Checking metered features
Before your customer uses a feature, you can check if the customer is allowed to use it and their current usage.ExampleLet’s imagine you have a free plan for a chatbot that allows 5 messages per month. Before your customer sends an AI message, you can check if they have any left.If they still have messages remaining, they’ll be allowed to send an AI message.
Checking for a required balance
If you know the balance a user will consume in advance, you can specify it with therequired_balance parameter. This means you can prevent a user from starting a process that would consume more than their current balance.
By default, required_balance 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 and reserving usage
You can check access and record usage in a single, atomic API call using thesend_event field. The usage value deducted from the balance will be the required_balance parameter. This is useful for concurrent events.
value in the track endpoint.
Checking boolean features
For simple on/off features, use the endpoint to determine if a customer has access. Alternatively you can just check if they have access to a certain plan.React

