Entitlements API
Complete guide to checking feature entitlements and usage limits via the API
Entitlements API
The Entitlements API allows you to check whether customers are entitled to specific features in your application. It supports both subscription-based and credit-based entitlements, providing real-time access control for your product features.
Overview
Entitlements determine what features customers can access based on:
- Subscription Plans: Features included in their current plan
- Feature Overrides: Manual overrides for specific customers
- Credit Grants: Time-limited credits that provide access to features
- Usage Limits: Numeric limits for metered features with real-time usage tracking
Entitlement Sources
Entitlements can come from four different sources:
plan
- Features included in the customer's subscription planoverride
- Manual overrides applied to specific customerscredits
- Credit-based entitlements with usage allowancesdefault
- Default fallback entitlements
Customer ID Types
The API supports two types of customer identification:
- Internal Customer ID: Your system's internal customer identifier
- External Customer ID: External identifiers from your application (set via
isExtCustId=true
)
Authentication
All API requests require authentication via merchant credentials.
Endpoints
Get All Customer Entitlements
Get all feature entitlements for a specific customer.
GET /api/entitlements/{customerId}?isExtCustId=false
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
customerId | string | ✓ | Customer ID (internal or external based on isExtCustId) |
isExtCustId | boolean | Whether customerId is external ID (default: false) |
Response
{
"entitlements": [
{
"entitled": true,
"feature": {
"slug": "api-calls",
"value": 1000
},
"source": "plan",
"usages": [
{
"metricId": "metric_123",
"usage": 150
}
],
"creditInfo": {
"creditAllowance": 0,
"creditsRemaining": 0,
"nextExpiryDate": null
}
},
{
"entitled": true,
"feature": {
"slug": "premium-support",
"value": true
},
"source": "credits",
"creditInfo": {
"creditAllowance": 1,
"creditsRemaining": 1,
"nextExpiryDate": "2024-02-01T00:00:00Z"
}
}
]
}
Check Specific Feature Entitlement
Check whether a customer is entitled to a specific feature.
GET /api/entitlements/{customerId}/feature/{featureSlug}?isExtCustId=false
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
customerId | string | ✓ | Customer ID (internal or external based on isExtCustId) |
featureSlug | string | ✓ | Slug identifier for the feature to check |
isExtCustId | boolean | Whether customerId is external ID (default: false) |
Response
{
"entitled": true,
"feature": {
"slug": "api-calls",
"value": 1000
},
"source": "plan",
"usages": [
{
"metricId": "metric_123",
"usage": 150
}
],
"creditInfo": {
"creditAllowance": 500,
"creditsRemaining": 350,
"nextExpiryDate": "2024-02-01T00:00:00Z"
}
}
Response Fields
Field | Type | Description |
---|---|---|
entitled | boolean | Whether customer is entitled to the feature |
feature | object | Feature details (null if not entitled) |
source | string | Source of entitlement: plan, override, credits, etc. |
usages | array | Usage metrics for numeric features |
creditInfo | object | Credit allowance and remaining balance |
Batch Check Feature Entitlements
Check multiple feature entitlements in a single request.
POST /api/entitlements/{customerId}/features?isExtCustId=false
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
customerId | string | ✓ | Customer ID (internal or external based on isExtCustId) |
isExtCustId | boolean | Whether customerId is external ID (default: false) |
Request Body
{
"featureSlugs": ["api-calls", "premium-support", "advanced-analytics"]
}
Request Fields
Field | Type | Required | Description |
---|---|---|---|
featureSlugs | string[] | ✓ | Array of feature slugs to check |
Response
{
"entitlements": [
{
"entitled": true,
"feature": {
"slug": "api-calls",
"value": 1000
},
"source": "plan",
"usages": [
{
"metricId": "metric_123",
"usage": 150
}
],
"creditInfo": {
"creditAllowance": 0,
"creditsRemaining": 0,
"nextExpiryDate": null
}
},
{
"entitled": false,
"feature": null,
"source": null,
"creditInfo": {
"creditAllowance": 0,
"creditsRemaining": 0,
"nextExpiryDate": null
}
}
]
}
Examples
Check All Customer Entitlements
curl -X GET '/api/entitlements/cust_123?isExtCustId=false' \
-H "Content-Type: application/json"
Check All Entitlements Using External Customer ID
curl -X GET '/api/entitlements/ext_user_456?isExtCustId=true' \
-H "Content-Type: application/json"
Check Specific Feature Entitlement
curl -X GET '/api/entitlements/cust_123/feature/api-calls' \
-H "Content-Type: application/json"
Batch Check Multiple Features
curl -X POST '/api/entitlements/cust_123/features' \
-H "Content-Type: application/json" \
-d '{
"featureSlugs": ["api-calls", "premium-support", "advanced-analytics"]
}'
Check Feature with External Customer ID
curl -X GET '/api/entitlements/ext_user_456/feature/api-calls?isExtCustId=true' \
-H "Content-Type: application/json"
Feature Types
Boolean Features
Boolean features are simple on/off switches that determine access to functionality.
{
"entitled": true,
"feature": {
"slug": "premium-support",
"value": true
},
"source": "plan"
}
Numeric Features
Numeric features have usage limits and provide real-time usage tracking.
{
"entitled": true,
"feature": {
"slug": "api-calls",
"value": 1000
},
"source": "plan",
"usages": [
{
"metricId": "api_calls_metric",
"usage": 150
}
]
}
Credit-Based Features
Features can be entitled through credit grants with expiration dates.
{
"entitled": true,
"feature": {
"slug": "ai-tokens",
"value": 50000
},
"source": "credits",
"creditInfo": {
"creditAllowance": 50000,
"creditsRemaining": 35000,
"nextExpiryDate": "2024-02-01T00:00:00Z"
}
}
Entitlement Logic
Credit-Based Entitlements
When customers have credit grants for a feature:
-
Numeric Features: Credits define the usage allowance
entitled = true
if usage < credit allowanceentitled = false
if usage >= credit allowanceentitled = null
if multiple metrics (let client decide)
-
Boolean Features: Credits provide access regardless of plan
entitled = true
if credits exist- Plan feature value is preserved but source indicates credits
Plan-Based Entitlements
Standard subscription plan entitlements:
- Features defined in the customer's active subscription
- Can be overridden at the customer level
- Support both boolean and numeric limits
Priority Order
Entitlements are resolved in this priority order:
- Credits - Always take precedence for numeric features
- Customer Overrides - Manual overrides for specific customers
- Plan Features - Features included in subscription plan
- Default - Fallback entitlements
Error Responses
400 Bad Request
{
"error": "featureSlugs array cannot be empty"
}
500 Internal Server Error
{
"error": "Failed to fetch entitlements"
}
{
"error": "Failed to check entitlement"
}
{
"error": "Failed to check entitlements"
}
Important Notes
Customer ID Resolution
- When
isExtCustId=true
, the API looks up the internal customer ID using the external identifier - External customer IDs must be unique within the merchant scope
- If external customer ID is not found, the API will treat it as internal ID for backward compatibility
Usage Tracking
- Usage metrics are calculated in real-time based on your event data
- Usage timeframes are aligned with billing periods when available
- Multiple metrics per feature are supported for complex usage scenarios
Credit Expiration
- Credits have expiration dates tracked in
nextExpiryDate
- Expired credits are automatically excluded from entitlement calculations
- Credit balances are calculated as:
allowance - current_usage
Performance Considerations
- Single feature checks are optimized for low latency
- Batch checks are more efficient for multiple features
- Usage calculations are cached when possible
Data Consistency
- Entitlements reflect real-time subscription and credit status
- Usage data may have slight delays based on event processing
- Failed metric queries default to zero usage
Integration Best Practices
- Cache Results: Cache entitlement results for performance
- Handle Null Values: Check for
entitled = null
on numeric features with multiple metrics - Monitor Usage: Use usage data to provide user feedback
- Credit Tracking: Monitor credit expiration dates for user notifications
- Error Handling: Implement fallback behavior for API failures
Merchant Isolation
- All entitlement checks are scoped to the authenticated merchant
- Customers and features from other merchants are not accessible
- Complete data isolation is maintained between merchants