/v1/apps/{app_id}/tenants/{tenant_id}/invitesAuthInvite an email address into a tenant. Returns the plaintext code once; only its SHA-256 digest is stored.
Path parameters
app_id*stringId of the app.
tenant_id*stringId of the tenant.
Headers
Idempotency-KeystringStripe-style idempotency key. A retried invite mint would otherwise send the invitee a second email carrying a second live code, and the first code stays valid — replay protection matters more here than on most creates. 24h TTL.
Request body
email*stringAddress the invite is bound to. The account created on accept gets this as its verified primary email, so it cannot be changed after mint — revoke and re-invite instead.
Example: "alice@example.com"
namestringHuman-readable name rendered in the invite email.
Example: "Alice Wong"
role_name*stringTenant-scoped role granted on accept. Case-insensitive lookup against this app's `role` table.
Example: "member"
max_usesnumberNumber of times the code may be redeemed. Defaults to 1. Values above 1 only matter for a code you intend to hand out manually — the first acceptance consumes the email binding, so a second accept of the same address is rejected regardless.
expires_in_hoursnumberHours until the invite expires. Defaults to 168 (7 days).
Response · 201
id*stringUnique identifier of the tenant invite.
tenant_id*stringThe tenant the tenant invite belongs to.
email*stringEmail address.
Example: "alice@example.com"
role_id*stringId of the role.
role_name*stringName of the role.
Example: "member"
status*objectDerived, never stored: revoked > expired > used > pending.
max_uses*numberHow many times the tenant invite can be used, or `null` for no limit.
Example: 1
use_count*numberHow many times the tenant invite has been used.
Example: 0
expires_at*string · date-timeWhen the tenant invite expires (ISO 8601), or `null` if it never does.
revoked_at*string · date-timeWhen the tenant invite was revoked (ISO 8601), or `null` while it is active.
invited_by*stringAccount id of the inviter. Null when the invite was minted by a Platform API Key, which has no account row — the audit log carries that attribution instead.
created_at*string · date-timeWhen the tenant invite was created (ISO 8601).
code*stringThe plaintext invite code, returned EXACTLY ONCE. Only its SHA-256 digest is stored, so this value cannot be recovered from the list endpoint or the database — if you lose it, revoke the invite and mint a new one. It is also mailed to the invitee through the app's `invite_template_name` Envoi slot.
Example: "tinv_9dK2mQ7pR4vXbN1sT6yZ0hLcJeW3fAgU"
Example
Request
POST https://api.auth.productcraft.co/v1/apps/{app_id}/tenants/{tenant_id}/invites
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"email": "alice@example.com",
"name": "Alice Wong",
"role_name": "member",
"max_uses": 0,
"expires_in_hours": 0
}import { Auth } from "@productcraft/auth";
// Admin routes read PRODUCTCRAFT_API_KEY; consumer routes need no key
const auth = new Auth();
const createTenantInvite = await auth.admin.app("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f").tenants.invites.create("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { email: "alice@example.com", role_name: "member" });auth.admin.app(…).tenants.invites.create(tenantId, params, options?): Auth.CreateTenantInvite
Response
{
"id": "string",
"tenant_id": "string",
"email": "alice@example.com",
"role_id": "string",
"role_name": "member",
"status": {},
"max_uses": 1,
"use_count": 0,
"expires_at": "2026-01-01T00:00:00.000Z",
"revoked_at": "2026-01-01T00:00:00.000Z",
"invited_by": "string",
"created_at": "2026-01-01T00:00:00.000Z",
"code": "tinv_9dK2mQ7pR4vXbN1sT6yZ0hLcJeW3fAgU"
}