Auth API reference

Auth API · Consumer-Auth

post/{app_slug}/v1/auth/switch-tenantAuth

Switch the active tenant for this session

Re-issues the EndUser's access + refresh tokens with the new `org_id` + `org_role` claims, after verifying the caller holds a tenant_membership for the target tenant. The session row is updated to the new tenant so subsequent refreshes preserve the context. The new access token keeps the session's `amr` and `mfa_at` (as `/auth/refresh` does), so a sign-in that completed MFA still proves it after a switch. Refresh-token rotation runs as usual; the previous refresh token enters the standard 60-second grace window.

Path parameters

app_slug*string

Slug of the app.

Request body

tenant_id*string

Tenant UUID to switch the EndUser's session into. Caller must already hold a tenant_membership row for this tenant in the app, else 403.

Example: "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f"

Response · 200 Tokens re-issued against the new tenant, carrying its `org_id` + `org_role` claims.

result*object

Always `session` here: a session was minted. Discriminates the sign-in results (`session`, `mfa_required`, `mfa_enrollment_required`).

access_token*string

Short-lived JWT signed with the app-scoped JWKS key. Carries sub, role, permissions[], type=end_user.

refresh_token*string

Long-lived opaque-ish JWT used to mint a new access token via /auth/refresh. Rotated on use.

token_type*string

Always `Bearer`.

Example: "Bearer"

expires_in*number

Access-token lifetime in seconds.

Example: 3600

password_warningsarray

Non-fatal notes about the password that was just set. Present only on `signup` and `accept-invite`, and only when the app runs `password_breach_check: "warn"` and the password was found in a public breach corpus — the value is then `["breached"]` and the session is minted anyway, so the client can prompt the user to change it. The key is ABSENT (not an empty array) when there is nothing to report; do not branch on its length without checking that it exists. Apps on the default `block` never see it — a breached password is refused with 400 `PASSWORD_BREACHED`.

Example: ["breached"]

mfa_enrollment_due_atstring · date-time

Present only when the app runs `mfa: "required"`, the user holds no enabled factor, and the account is still inside `mfa_grace_days` of its creation. The session IS minted; this is the deadline after which sign-in will start returning `mfa_enrollment_required` instead, so a client can prompt rather than block. Absent in every other case.

Example

Request

POST https://api.auth.productcraft.co/{app_slug}/v1/auth/switch-tenant
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "tenant_id": "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f"
}

Response

{
  "result": {},
  "access_token": "string",
  "refresh_token": "string",
  "token_type": "Bearer",
  "expires_in": 3600,
  "password_warnings": [
    "breached"
  ],
  "mfa_enrollment_due_at": "2026-01-01T00:00:00.000Z"
}