Check access
allows() return false and enforce() throw an EntitlementDeniedError. Network and authentication errors throw in all three.
The customer to check. Required with a secret key; omit it on a
withToken() client to check that
user.For a quota counted per machine, project or seat: which one. See Dimensions.
Read the result
check() and consume() return:
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:
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.
check(). When allowed is false, nothing was recorded.
A whole number. Fractions are rejected, not rounded, so count in the smallest unit you bill.
See Dimensions.
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. Passdimension 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
allowed field because the list can be up to 60 seconds old: decide whether an action may run with check() or consume().
