A unified method to check any type of feature entitlement. It automatically returns the appropriate entitlement type based on the feature configuration.You provide the customer ID and feature ID. Optionally, pass a resource ID for multi-subscription products, or a requested usage amount to proactively check if additional usage would be allowed (metered features only).
const entitlement = await stiggClient.getEntitlement({ customerId: 'customer-demo-01', featureId: 'feature-demo-01', resourceId: 'resource-01', // optional, pass it to get entitlement of specific resource});if (entitlement.hasAccess) { // Customer has access to the feature} else { // Access denied console.log('Access denied reason:', entitlement.accessDeniedReason);}// Entitlement contains the specific entitlement details// based on feature type (boolean, numeric, or metered)switch (entitlement.type) { case "NUMERIC": console.log('Numeric value:', entitlement.value); break; case "METERED": console.log('Usage limit:', entitlement.usageLimit); console.log('Current usage:', entitlement.currentUsage); break; case "BOOLEAN": break;}
Check whether a customer’s usage of a metered feature is within the allowed quota. You can optionally provide a requested usage amount to proactively verify if a specific amount of additional usage would be allowed before performing the action.
const entitlement = await stiggClient.getMeteredEntitlement({ customerId: 'customer-demo-01', featureId: 'feature-demo-03', resourceId: 'resource-01', // optional options: { requestedUsage: 10 // optional, proactively check usage },});if (entitlement.hasAccess) { // has access and the requested usage is within the allowed quota} else { // the customer has exceeded his quota for this feature}
Retrieve all entitlements for a customer (or a specific resource), returning the full list of features they have access to along with usage limits and current usage.