From a new account to your first gated request
Six short steps. If you already have a .NET app, budget about fifteen minutes for the server side. We have not timed it on your stack, so treat that as a guide, not a promise.
Steps
Create your application
In the console open Applications, choose Add application, and copy the application slug. Starter gives you one application that runs in Production, and up to five customer workspaces.
Make a server key with only the scopes you need
Open API keys and create a key. For this walkthrough, applications.read (to read the runtime context) and tenants.write (to create workspaces and record usage) are enough. The value is shown once, so put it in your secret manager. Never ship it to a browser or a mobile app.
Install the .NET SDK and create the client
The NuGet package is the published SDK. Other languages call the same REST API with the key in the X-TenancyEngine-Api-Key header; the TypeScript and other language packages are not published yet.
Install, then register the client dotnet add package TenancyEngine.Sdk --version 2.3.0 builder.Services.AddHttpClient("TenancyEngine", c => c.BaseAddress = new Uri("https://api.saasruntime.com")); builder.Services.AddSingleton(sp => new TenancyEngineClient( sp.GetRequiredService<IHttpClientFactory>().CreateClient("TenancyEngine"), builder.Configuration["TenancyEngine:ApiKey"]));Define a free offering, then create your first customer workspace
Under your application, add a feature or two and an offering that costs nothing. A new workspace has no plan until you give it one, and metered calls fail until it does, so start it on the free offering.
Create a workspace on a free offering var app = await te.GetApplicationAsync("my-app", ct) ?? throw new InvalidOperationException("Application not found."); // "free" is the slug of a free offering you defined for this application. var tenant = await te.CreateTenantAsync( app.Id, new CreateTenantRequest("Acme Bakery", "acme-bakery", Environment: "Production") { OfferingSlug = "free" }, ct);Check the plan, then record the use
Before the work, ask what the customer is entitled to. After it, record the use with a key that stays the same on a retry, such as a job id, so a repeated request is not counted twice.
Gate and meter a request // 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.Point your sign-in at TenancyEngine
Your app is a standard OpenID Connect client using the authorization code flow with PKCE and no client secret. The authority in production is https://auth.saasruntime.com; the client id comes from the console. Any maintained OpenID Connect library works.
Honest limits
Before you start
- Starter has no subscription billing and no development or staging environments. Those start on Growth.
- Starter runs in Production only, so use a test customer, not real customer data, while you learn.
- SAML single sign-on is not offered. SCIM 2.0 directory sync is.
- The code above uses the published .NET SDK. We have not published SDKs for other languages yet.
Where to go next
Start on the free plan
One app and five customer workspaces. No credit card required.