Skip to main content

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 replaces if (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, uses bool_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.
Because this replaces the whole set, sending only the feature you changed deletes the rest. Send the full list every time. Feature keys must match ^[A-Za-z0-9][A-Za-z0-9._:-]*$; duplicate keys in one request are rejected with validation_failed.
A customer holding several subscriptions gets the union: booleans resolve any-true wins, limits resolve maximum wins, and only 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
For latency-sensitive paths, cache check results for a short TTL (30–60s) keyed by customer_id:feature. Entitlements only change when a plan or subscription changes, so a short cache is safe and removes the round-trip.

Step 3: Enforce a limit

For limit entitlements, compare the entitled ceiling to your own counter:
Node

Step 4: Wire usage headroom

When a limit’s feature_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
See the usage tutorial for the full metering flow.

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 contributing plan_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