Skip to main content
POST
/
v1
/
subscriptions
/
plans
/
{plan_id}
/
entitlements
JavaScript
import Hercules from '@usehercules/sdk';

const client = new Hercules({
  apiVersion: '2025-12-09',
  apiKey: process.env['HERCULES_API_KEY'], // This is the default and can be omitted
});

const planEntitlement = await client.beta.subscriptions.plans.entitlements.attach('plan_id', {
  entitlement: 'entitlement',
});

console.log(planEntitlement.id);
{
  "id": "<string>",
  "entitlement": {
    "id": "<string>",
    "name": "<string>",
    "key": "<string>",
    "active": true,
    "livemode": true
  }
}

Authorizations

Authorization
string
header
required

API key authentication. Include your API key in the Authorization header as: Bearer

Path Parameters

plan_id
string
required

The unique identifier of the plan

Body

application/json

Request to attach an entitlement to a plan. All customers subscribed to this plan will gain access to the feature.

entitlement
string
required

The ID of the entitlement to attach to the plan

Response

201 - application/json

The plan-entitlement attachment object

An entitlement attached to a plan. All customers subscribed to the plan gain access to this entitlement.

id
string
required

Unique identifier for the entitlement

entitlement
object
required

The entitlement attached to the plan