const { result, error } = await unprice.customers.can({
  customerId: "cus_1234567890",
  featureSlug: "tokens",
  metadata: {
    action: "create",
    country: "US"
  }
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "success": true,
  "message": "Feature is available",
  "deniedReason": null,
  "cacheHit": false,
  "remaining": 900
}
const { result, error } = await unprice.customers.can({
  customerId: "cus_1234567890",
  featureSlug: "tokens",
  metadata: {
    action: "create",
    country: "US"
  }
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "success": true,
  "message": "Feature is available",
  "deniedReason": null,
  "cacheHit": false,
  "remaining": 900
}

Request

customerId
string
required
The ID of the customer to check feature access for
featureSlug
string
required
The slug of the feature to check access for
metadata
object
Additional metadata to consider when checking access. This can include information like the action being performed or the user’s location

Response

success
boolean
required
Whether the customer can use the feature
message
string
A human-readable message explaining the result
deniedReason
string
The reason why access was denied. Possible values:
  • “RATE_LIMITED”
  • “CUSTOMER_SUBSCRIPTION_NOT_FOUND”
  • “ENTITLEMENT_NOT_FOUND”
  • “LIMIT_EXCEEDED”
  • “ENTITLEMENT_EXPIRED”
  • “ENTITLEMENT_NOT_ACTIVE”
cacheHit
boolean
Whether the result was served from cache
remaining
number
The remaining usage quota for the feature