TenancyEngine SDKs
Every SDK talks to the same org-API-key-authenticated runtime surface (/api/v1/runtime/* on SaaSRuntime.Api) or, for the browser SDK, the anonymous public-app surface (/api/v1/public/apps/*). Pick the SDK for your backend language, or the client SDK for the platform your app runs on -- see Server-side vs. client-side: which SDK do I want? if you are not sure which bucket your app is in.
Every install command and code sample below comes from that SDK's own README. Where a package is not yet on a public registry, the table says how to install it.
Server-side SDKs (secret organization API key)
Your backend holds a secret organization API key (X-TenancyEngine-Api-Key) and calls the runtime surface directly -- create tenants, gate features, record usage, run AI extraction, send SMS, issue storage grants. Never ship this key to a browser or mobile app.
| Language | Package | Install | Status |
|---|---|---|---|
| .NET | TenancyEngine.Sdk | dotnet add package TenancyEngine.Sdk --version 2.3.0 --source https://api.nuget.org/v3/index.json | Current version 2.3.0, released on nuget.org; no private-feed credentials required. Upgrading from 2.0.2 needs no code changes: see the changelog and migration note |
| TypeScript / Node.js | @tenancyengine/sdk | npm install @tenancyengine/sdk | Current version 0.8.0, on npm (0.5.0 to 0.8.0 are published); no credentials required. History: changelog |
| Go | github.com/sathish4000/tenancyengine-go | go get github.com/sathish4000/tenancyengine-go | Not yet public: go get cannot resolve this module today (the module path returns 404). Contact us for early access |
| Python | tenancyengine | pip install tenancyengine | Public registry release coming soon; contact us for early access |
| Java | com.tenancyengine:tenancyengine-sdk | Maven/Gradle coordinate above | Public registry release coming soon; contact us for early access |
| PHP | tenancyengine/sdk | composer require tenancyengine/sdk | Public registry release coming soon; contact us for early access |
| Ruby | tenancyengine | gem install tenancyengine | Public registry release coming soon; contact us for early access |
Server SDKs without a public registry release yet are available on request. Contact us for early access.
The .NET runtime API base in production is https://api.saasruntime.com. The OIDC authority is https://auth.saasruntime.com; configure it separately in your application's OIDC handler, not as the SDK's API base. Use the approved matching API/authority pair for lab or staging.
Quickstart: .NET
using TenancyEngine.Sdk;
using var httpClient = new HttpClient { BaseAddress = new Uri("https://api.saasruntime.com") };
var client = new TenancyEngineClient(httpClient, apiKey: Environment.GetEnvironmentVariable("TE_API_KEY")!);
var app = await client.GetApplicationAsync("your-app-slug")
?? throw new InvalidOperationException("Application not found.");
// Omitting Environment creates the tenant in Production. A key limited to Development (the default for application
// keys since #1370) is refused with 403 environment_not_allowed, so name the environment the key is allowed to use.
var tenant = await client.CreateTenantAsync(app.Id, new CreateTenantRequest("Acme Corp", "acme", Environment: "Development"));
await client.ConsumeUsageAsync("your-app-slug", "acme", "Development", "api_calls", amount: 1,
idempotencyKey: "req-" + Guid.NewGuid());Quickstart: TypeScript / Node.js
import { TenancyEngineClient } from '@tenancyengine/sdk';
const te = new TenancyEngineClient({
baseUrl: process.env.TENANCYENGINE_BASE_URL ?? 'https://api.saasruntime.com',
apiKey: process.env.TENANCYENGINE_API_KEY!,
appId: process.env.TENANCYENGINE_APP_ID!,
});
const app = await te.getApplication('your-app-slug');
const ctx = await te.getRuntimeContext('your-app-slug', 'Production', tenantId);Quickstart: Go
import tenancyengine "github.com/sathish4000/tenancyengine-go"
client, err := tenancyengine.New("https://auth.saasruntime.com", "te_your_organization_api_key")
if err != nil {
log.Fatal(err)
}
app, err := client.GetApplication(ctx, "your-app-slug")Quickstart: Python
from tenancyengine import TenancyEngineClient
client = TenancyEngineClient(
api_key="te_...",
base_url="https://api.saasruntime.com",
)
app = client.get_application("your-app-slug")
ctx = client.get_runtime_context("your-app-slug", environment="Production")Quickstart: Java
TenancyEngineClient client = TenancyEngineClient.builder(
"https://api.saasruntime.com",
System.getenv("TENANCYENGINE_API_KEY"))
.build();
Application app = client.getApplication("acme-app");
Tenant tenant = client.createTenant(app.id(),
CreateTenantRequest.builder("Acme Corp", "acme-corp").build());Quickstart: PHP
$client = new TenancyEngineClient(new ClientConfig(
baseUri: 'https://auth.saasruntime.com',
apiKey: getenv('TENANCYENGINE_API_KEY'),
));
$app = $client->applications()->get('my-app-slug');
$scoped = $client->forApplication($app->slug, $app->id);
$tenant = $scoped->createTenant('Acme Inc', 'acme', ReleaseChannel::Stable, ApplicationEnvironmentKind::Production);Quickstart: Ruby
require "tenancyengine"
client = TenancyEngine::Client.new(api_key: "te_...", base_url: "https://api.saasruntime.com")
app = client.get_application("your-app-slug")
ctx = client.get_runtime_context("your-app-slug", environment: "Production")Client-side SDKs (no secret -- publishable credential or PKCE)
Anything that ships to an end user's browser or device must never hold your secret organization API key. Two different credential models apply depending on where your app runs -- see Mobile and browser apps: which credential model do I use?.
| Platform | Package | Install | Status |
|---|---|---|---|
| Browser (script tag) | -- | CDN script tag | Not yet deployed -- the CDN host is not wired up yet; build dist/cdn/tenancyengine.js locally with npm run build:cdn in src/BrowserSdk in the meantime |
| Browser (npm) | @tenancyengine/browser-sdk | npm install @tenancyengine/browser-sdk | Not yet published (404 on the public npm registry) -- build from source in src/BrowserSdk |
| .NET MAUI | TenancyEngine.Sdk.Maui | dotnet add package TenancyEngine.Sdk.Maui --version 0.4.3 --source https://api.nuget.org/v3/index.json | Released on nuget.org; signed environment enrollment and MAUI configuration. Mobile authentication is in TenancyEngine.Sdk.Maui.Auth 0.4.3. |
| iOS / Swift | TenancyEngineAuth (Swift Package) | Swift Package Manager, local path | Source-complete with a full README; not yet published as a remote git dependency |
| Android / Kotlin | com.tenancyengine:tenancyengine-auth | Gradle composite build (includeBuild(...)) | Source-complete; explicitly not on any Maven feed -- its own README calls out this exact "do not assume a package id is live" trap |
| Flutter | tenancyengine_auth | flutter pub add tenancyengine_auth | Not yet published to pub.dev -- use a git/path dependency |
| React Native | @tenancyengine/react-native-auth | npm install @tenancyengine/react-native-auth react-native-app-auth react-native-keychain | Not published (404 on the public npm registry) -- use a file:/git dependency |
Quickstart: Browser SDK
import { createClient } from '@tenancyengine/browser-sdk';
const te = createClient({ appSlug: 'my-app' });
const app = await te.apps.getApp();
const offerings = await te.apps.getOfferings();This SDK cannot call anything under /api/v1/runtime/* -- no tenant creation, no AI extraction, no usage metering. Those need your secret key on your own backend; the browser SDK's BackendProxyClient is a thin fetch wrapper for calling your own API, which then calls TenancyEngine server-side.
MCP (AI assistant connector)
Your customers (or your own team) can connect Claude Desktop, Claude Code, ChatGPT, or any other Model Context Protocol client directly to one application's own data via POST /api/v1/runtime/mcp (Streamable HTTP, JSON-RPC 2.0), authenticated with an application-scoped API key carrying mcp.connect. Full setup and per-client config snippets: Connect an AI assistant (MCP).
Related
- Getting started -- create an app, mint a key, make your first call
- Mobile and browser apps -- credential model and OIDC client registration
- AI credits -- pay-as-you-go AI extraction/chat pricing and balance management
- SDK changelog and migration -- .NET 2.0.2 to 2.18.0, npm 0.5.0 to 0.8.0, and what secrets, jobs and cache do and do not cover
- Private structured inference (.NET) -- consent-gated, schema-validated AI results from a person's data, with no AI provider key in your app
- App staff authorization -- issuer, audience, permission claim and revocation for your own staff, separate from customer roles and platform operators
- Web app access-token check (.NET) -- verify the access token a cookie-session web app saved, then confirm the platform still honours it, in one call
- Scheduled jobs (.NET) -- recurring jobs with leader election (at-least-once, so jobs must be idempotent), history, timeouts and a protected diagnostics endpoint, through this one SDK. Private-feed build only: the nuget.org package does not contain the facade (compile error, namespace missing)
- Customer sign-in (.NET) -- subscriber onboarding and login
- Public access requests -- the request-access gate for approval-based signup
- Policy storage responsibility -- what the platform stores and audits, and what your app must keep
- App access path -- register an app, OAuth client, scopes, tenant membership, machine tokens, lanes
- Platform caching -- opt-in Upstash-backed Redis caching
- API keys -- creating and revoking organization keys in console
Which version do I need?
One minimum version per capability. "Published" is what nuget.org and npm serve (checked 2026-11-02: nuget.org 2.3.0, npm 0.8.0); a version above that is in the repository only and is listed in the changelog.
| Capability | .NET TenancyEngine.Sdk minimum | @tenancyengine/sdk minimum |
|---|---|---|
Runtime calls, webhooks (v1 signature) | 2.0.2 | 0.5.0 |
| Customer machine access | 2.1.0 | n/a |
Effective entitlements (RuntimeContext.Entitlement) | 2.2.0 | n/a |
Webhook secret overlap (v1_previous) | 2.3.0 | n/a |
| App chat | 2.4.0 (not on nuget.org yet) | n/a |
| MCP resource server helpers | 2.5.0 (not on nuget.org yet) | n/a |
| Entitlement cache, Standard Webhooks | 2.7.0 (not on nuget.org yet) | n/a |
| Lane contract | 2.9.0 (not on nuget.org yet) | 0.6.0 |
| .NET 10 asset | 2.11.0 (not on nuget.org yet) | n/a |
| Current-authority check (token introspection) | 2.12.0 (not on nuget.org yet) | 0.8.0 |
Getting a package that is not on the public registry
If you need a .NET version above the published one, you have two supported routes: wait for the public release (tracked in tenancyengine#1195, a human-confirmed dispatch), or use the private feed nuget.cyntrix.ca, which needs a read-only feed credential. Without that credential the feed answers 401. Do not vendor a copy of the package.