Roles and entitlements

Define roles and plans once, then check them with one call

Name the roles your customers need, define the plans you sell, and set a limit on any feature. Your backend asks what a customer may do and records what they use.

Roles, features, and plans on every plan. Separate development and staging environments, and promoting between them, start on Growth.

What you get

Roles and claims

Define named roles for the people in each customer workspace and map them to claims. Mark a claim as included in the token and your app reads it straight from the access token.

Plans with feature limits

Create the plans you sell, attach features to them, and set a limit on any feature, such as 100 reports a month. Assign a plan to a customer and the limits apply.

One call to check access

The runtime context returns the customer’s enabled features, limits, current usage, and status. It is the one call your backend makes before doing tenant work.

Usage that survives retries

Record usage with an idempotency key so a retry never counts twice. Counter meters reset each period. Gauge meters, such as seats, can also be released.

Warnings before the limit

TenancyEngine sends a usage.near_limit webhook when a customer passes 80 percent of a limit and usage.at_limit when they reach it, once for each crossing.

Safe to cache, never stale for long

The entitlement snapshot says how long you may use it, never more than five minutes. When it expires, fetch it again. If that fails, deny the features that depend on the plan.

Promote with a diff

Build in development, check in staging, and promote to production after reviewing what changed. This starts on Growth.

In your code

These calls come from the TenancyEngine.Sdk package on NuGet. Every capability is also a REST API, so any language that can make an HTTPS request can use it.

Check a customer’s plan, then record the use
// A customer calls your API: check their plan, then meter the call.
var context = await te.GetRuntimeContextAsync("my-app", "Production", tenantId, ct);
if (context is null || !context.Features.Contains("reports"))
    return Results.StatusCode(StatusCodes.Status403Forbidden);

await te.ConsumeUsageAsync("my-app", tenantSlug, "Production", "reports",
    amount: 1, idempotencyKey: $"report-{requestId}", ct: ct);
// requestId is the id of this request or job, so a retry is counted once.
Reuse a plan answer only while it is fresh
// A plan answer may be reused only for a short, bounded time.
var context = await te.GetRuntimeContextAsync("my-app", "Production", tenantId, ct);
var entitlement = context?.Entitlement;

if (entitlement is null || !entitlement.IsUsableAt(DateTimeOffset.UtcNow))
    return Results.StatusCode(StatusCodes.Status503ServiceUnavailable); // fail closed

var plan = entitlement.OfferingSlug ?? "none";

What to know before you build on it

  • Release works on gauge meters only. A counter that resets each month cannot be released.
  • Starter has no separate development or staging environment, so there is nothing to promote.
  • Usage meters count what your app reports. TenancyEngine does not see your traffic.

Questions developers ask

What is the difference between my TenancyEngine plan and the plans I sell?

Your TenancyEngine plan (Starter, Growth, Scale, or Enterprise) sets what you can build, such as how many apps and customer workspaces. The plans you define for your customers decide which features each customer gets.

What happens if a retry sends the same usage twice?

Send the same idempotency key with the retry. The second call is recognised as a replay and does not count again.

How do I learn that a customer changed plans?

TenancyEngine sends an entitlement.changed webhook to your endpoints. Fetch the customer’s runtime context again when it arrives.

Try it on the free Starter plan

One app and up to five customer workspaces. Upgrade when you need more.

Request access