Nest Authbeta

POST /auth/switch-tenant

Switch Active Tenant

Switch Active Tenant

POST/auth/switch-tenant

Request body

NestAuthSwitchTenantRequestDto

FieldTypeRequiredDescription
tenantIdstringrequiredTenant ID to switch into
Example: 123e4567-e89b-12d3-a456-426614174000

Examples

Example
{
  "tenantId": "123e4567-e89b-12d3-a456-426614174000"
}

Responses

200

AuthWithTokensResponseDto

FieldTypeRequiredDescription
accessTokenstringrequiredJWT access token (short-lived)
Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJpYXQiOjE2OTk5OTk5…
refreshTokenstringrequiredJWT refresh token (long-lived)
Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ0eXBlIjoicmVmcmVz…
messagestringoptionalSuccess message (added by controller based on configuration)
Example: Login successful
isRequiresMfabooleanrequiredWhether multi-factor authentication is required
Example: false
mfaMethods"email" | "sms" | "totp"[]optionalAvailable MFA methods when isRequiresMfa is true
Example: ["email","totp"]
defaultMfaMethod"email" | "sms" | "totp"optionalDefault/recommended MFA method
emailsmstotp
Example: email
trustTokenstringoptionalTrust token for trusted device verification
Example: 1234567890

Example response

{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJpYXQiOjE2OTk5OTk5OTksImV4cCI6MTY5OTk5OTk5OX0.xyz",
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ0eXBlIjoicmVmcmVzaCIsImlhdCI6MTY5OTk5OTk5OX0.abc",
  "message": "Login successful",
  "isRequiresMfa": false,
  "mfaMethods": [
    "email",
    "totp"
  ],
  "defaultMfaMethod": "email",
  "trustToken": "1234567890"
}

Try it

curl -X POST 'https://api.example.com/auth/switch-tenant' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -d '{"tenantId":"123e4567-e89b-12d3-a456-426614174000"}'

On this page