Skip to main content

Check access

All three run the same check. A denial makes allows() return false and enforce() throw an EntitlementDeniedError. Network and authentication errors throw in all three.
string
required
The feature key, as set in the dashboard.
string
The customer to check. Required with a secret key; omit it on a withToken() client to check that user.
number
default:"1"
For a quota: whether the customer can use this many more units.
string
For a quota counted per machine, project or seat: which one. See Dimensions.

Read the result

check() and consume() return:
When a quota’s overage is ALLOW or BILL, remaining goes negative past limit while allowed stays true: the customer hasn’t hit a wall. Check overage_behavior before showing “limit reached”.
configured: false always comes with allowed: false: the key doesn’t exist, or no plan, default plan or override grants the feature. Don’t treat it as open by default.

Handle a denial

enforce() throws an EntitlementDeniedError with the full result in .check, so a guard can tell why without a second call:
It has code: 'ENTITLEMENT_DENIED' and statusCode: 403. The SDK raises it after a successful check, so it has no requestId.

Consume a quota

When the action you gate is the usage itself, consume() checks the limit and records the usage in one atomic step, so two concurrent requests can’t both pass a blocked limit.
It returns the same result as check(). When allowed is false, nothing was recorded.
string
Required with a secret key. The customer must already exist: consume() never creates one.
number
default:"1"
A whole number. Fractions are rejected, not rounded, so count in the smallest unit you bill.
string
A retry with the same key returns the first result instead of counting again.
string
consume() only works on quota features. On a boolean or static feature it throws a ValidationError.

Dimensions

A quota can be counted per machine, project or seat. Pass dimension to say which one:
A dimension on a feature that has none is rejected, and so is a missing one when the plan counts per dimension. A customer can use up to 1,000 dimensions per feature per period; a call naming a new one past that is refused.

List entitlements

Every entitlement in one call, for a “your plan” screen. Entries have no allowed field because the list can be up to 60 seconds old: decide whether an action may run with check() or consume().