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.
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.
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.
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.
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.
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.
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.
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.
Build in development, check in staging, and promote to production after reviewing what changed. This starts on Growth.
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.
// 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.// 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";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.
Send the same idempotency key with the retry. The second call is recognised as a replay and does not count again.
TenancyEngine sends an entitlement.changed webhook to your endpoints. Fetch the customer’s runtime context again when it arrives.
One app and up to five customer workspaces. Upgrade when you need more.
Request access