/v1/apps/{app_id}/tenantsAuthCreate a tenant in this app. Auth-admin lane; requires auth.tenant.create on the app URN.
Path parameters
app_id*stringId of the app.
Headers
Idempotency-KeystringStripe-style idempotency key. Tenant creation mints a fresh `tnt_<...>` public id that downstream audit + webhook fan-out reference; a retry without this header creates a second tenant your IaC can't consolidate. 24h TTL.
Request body
display_name*stringHuman-readable display name shown in the customer UI.
Example: "Acme Co"
slugstringOptional URL-safe slug, unique per app (case-insensitive). When omitted, derived from display_name; collisions retried with a random suffix.
Example: "acme-co"
metadataobjectFree-form metadata; opaque to Auth. Customer-controlled.
Example: {"plan":"pro","region":"eu-west"}
Response · 201 Created tenant.
id*stringUnique identifier of the tenant.
display_id*stringCustomer-facing prefixed identifier.
Example: "tnt_3a9f2b1c0d4e"
app_id*stringThe Auth app the tenant belongs to.
slug*stringURL-safe identifier of the tenant, unique within its parent.
Example: "acme-org"
display_name*stringHuman-readable name of the tenant.
Example: "Acme Org"
status*objectTenant status: `active`, `suspended` or `archived`.
metadata*objectFree-form JSON object you attach to the tenant; returned as stored.
created_at*string · date-timeWhen the tenant was created (ISO 8601).
updated_at*string · date-timeWhen the tenant was last changed (ISO 8601).
Example
Request
POST https://api.auth.productcraft.co/v1/apps/{app_id}/tenants
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"display_name": "Acme Co",
"slug": "acme-co",
"metadata": {
"plan": "pro",
"region": "eu-west"
}
}import { Auth } from "@productcraft/auth";
// Admin routes read PRODUCTCRAFT_API_KEY; consumer routes need no key
const auth = new Auth();
const tenant = await auth.admin.app("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f").tenants.create({ display_name: "Acme Co" });auth.admin.app(…).tenants.create(params, options?): Auth.Tenant
Response
{
"id": "string",
"display_id": "tnt_3a9f2b1c0d4e",
"app_id": "string",
"slug": "acme-org",
"display_name": "Acme Org",
"status": {},
"metadata": {},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z"
}