Skip to content

Overview

Entitlements define which features each subscription plan includes. They work alongside feature flags to control commercial access to features.

Base URL

/api/platform/entitlements

NOTE

These endpoints require authentication with a Super Admin account.


Endpoints

List Entitlement Features

http
GET /api/platform/entitlements/features

Returns all defined entitlement features.

Response 200 OK

json
[
  {
    "id": "ai_generation",
    "name": "AI Content Generation",
    "type": "BOOLEAN",
    "category": null,
    "defaultEnabled": false,
    "defaultValue": null
  },
  {
    "id": "ai_website_analysis",
    "name": "Website Analysis",
    "type": "NUMBER",
    "category": "ai_refinement",
    "defaultEnabled": false,
    "defaultValue": 0
  }
]

Create Entitlement Feature

http
POST /api/platform/entitlements/features

Request Body

json
{
  "id": "custom_branding",
  "name": "Custom Branding",
  "description": "Allow custom logo and colors",
  "type": "boolean",
  "category": "appearance",
  "defaultEnabled": false,
  "defaultValue": null
}
FieldTypeRequiredDescription
idstringCode-defined ID (used in code checks)
namestringHuman-readable name
descriptionstringFeature description
typestringboolean or number (default: boolean)
categorystringGrouping category
defaultEnabledbooleanDefault enabled state
defaultValuenumberDefault numeric value

Response 201 Created


List Packages

http
GET /api/platform/entitlements/packages

Returns all subscription packages for the entitlements matrix.

Response 200 OK

json
[
  { "id": "pkg-1", "name": "free" },
  { "id": "pkg-2", "name": "starter" },
  { "id": "pkg-3", "name": "professional" },
  { "id": "pkg-4", "name": "enterprise" }
]

List Plan Entitlements

http
GET /api/platform/entitlements/plans

Returns the full entitlements matrix (all package-feature mappings).

Response 200 OK

json
[
  {
    "id": "pe-123",
    "packageId": "pkg-1",
    "featureId": "ai_generation",
    "enabled": true,
    "value": -1
  },
  {
    "id": "pe-456",
    "packageId": "pkg-1",
    "featureId": "ai_website_analysis",
    "enabled": true,
    "value": 1
  }
]
FieldTypeDescription
enabledbooleanWhether feature is enabled for this plan
valuenumberNumeric limit. -1 = unlimited, 0 = disabled

Update Plan Entitlement

http
PUT /api/platform/entitlements/plans/:packageId/:featureId

Parameters

NameTypeDescription
packageIdstringPackage/plan ID
featureIdstringEntitlement feature ID

Request Body

json
{
  "enabled": true,
  "value": 50
}
FieldTypeRequiredDescription
enabledbooleanWhether feature is enabled
valuenumberNumeric limit (default: -1 for unlimited)

Response 200 OK - Updated entitlement object


Checking Entitlements in Code

Boolean Entitlements

typescript
import { FeatureAccessService } from '../services/featureAccessService.js';

const hasAccess = await FeatureAccessService.checkEntitlement(
  'advanced_analytics',
  companyId
);

Numeric Entitlements (AI Usage)

typescript
import { entitlementsService } from '../services/entitlements.service.js';

// Check if action is allowed and get remaining usage
const result = await entitlementsService.checkAIAction(
  companyId,
  'WEBSITE_ANALYSIS'
);
// Returns: { allowed: true, remaining: 5, limit: 10, used: 5 }

// Get complete usage summary
const summary = await entitlementsService.getUsageSummary(companyId);

Entitlement Value Conventions

ValueMeaning
-1Unlimited
0Disabled / No access
1Enabled (for boolean types)
> 1Numeric limit (for number types)

Seeded Entitlement Features

The following entitlements are seeded by default:

IDNameType
ai_generationAI Content Generationboolean
advanced_analyticsAdvanced Analyticsboolean
team_collaborationTeam Collaborationboolean
ai_posts_limitMonthly AI Posts Limitnumber
social_accounts_limitSocial Accounts Limitnumber
docs.clientDocs: Clientboolean
docs.apiDocs: APIboolean
docs.internalDocs: Internalboolean
docs.aiDocs: AIboolean
ai_website_analysisWebsite Analysisnumber
ai_field_analysisField Analysisnumber
ai_one_shot_refinementOne-Shot Refinementnumber
ai_chat_sessionsChat Sessionsnumber
ai_chat_messages_per_sessionMessages Per Chat Sessionnumber

See Also

TendSocial Documentation