What you’ll build
This tutorial gates product features by plan without hard-coding plan names into your app. You’ll grant boolean and limit entitlements to a plan, check them on the hot path with a single endpoint, and wire a usage limit so your dashboard can show remaining headroom. The pattern replacesif (plan === 'pro') scattered through your codebase with
if (entitled(customer, 'sso')). Change what a plan includes in Recurso and
every subscriber picks it up immediately — no deploy.
Recurso resolves whether a customer is entitled and how much. Counting
actual consumption against a limit is your application’s job. For metered
billing on that consumption, see usage-based billing.
Step 1: Define plan entitlements
Entitlements come in two kinds: boolean (on/off, usesbool_value) and
limit (a numeric quota, uses limit_value). Setting a plan’s entitlements
is a full replacement — always send the complete set the plan should grant.
active and
trialing subscriptions count. See
Entitlements
for the full resolution rules.
Step 2: Check a feature at request time
GET /v1/entitlements/check is the hot path — one indexed query for a
customer_id + feature pair. A feature the customer doesn’t have answers
granted: false with a null limit; it is never a 404.
Gate a route with middleware
Node
Step 3: Enforce a limit
Forlimit entitlements, compare the entitled ceiling to your own counter:
Node
Step 4: Wire usage headroom
When a limit’sfeature_key matches a usage dimension of the same name,
GET /v1/subscriptions/{id}/usage joins the limit and remaining headroom into
each row automatically — the “4,231 of 10,000” view, without you doing the math.
Node
Step 5: See why a customer has a feature
To display why a feature is granted (which plans contributed), fetch the effective set for the customer — each entry lists the contributingplan_ids:
Next Steps
Entitlements
Full resolution semantics and validation rules
Check Feature API
The hot-path check endpoint reference
Usage-Based Billing
Meter and bill on consumption
Set Plan Entitlements API
Replace a plan’s grants