Skip to content

Extend the open tenant switch

PATCH
/api/v1/tenant/switch
curl --request PATCH \
--url http://localhost:3000/api/v1/tenant/switch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "expiresAt": "2026-04-15T12:00:00Z", "reason": "example" }'

Moves the expiry of the caller’s own open switch to a later time, at most 72 hours from now, with a reason (3-500 characters). Only a superadmin or support user holds switches. One audit entry (action extend) records the reason and the previous and new expiry. Not available to API keys.

x-organization-id
string format: uuid

UUID of the organization (tenant) the request acts in. It selects the tenant and grants nothing: the server checks membership or an open tenant switch. Not needed for global operations. A malformed value returns 400. API keys are fixed to their own organization; another organization returns 403. The x-organization-source header grants nothing.

Media typeapplication/json
object
expiresAt
required

New expiry (ISO 8601): later than the current expiry and at most 72 hours from now.

string format: date-time
reason
required

Why the switch is extended (3-500 characters after trimming)

string
>= 3 characters <= 500 characters
Examplegenerated
{
"expiresAt": "2026-04-15T12:00:00Z",
"reason": "example"
}

Switch extended

Media typeapplication/json
object
id
required

Switch record ID

string
userId
required

User ID who performed the switch

string
fromOrgId

Original organization ID

string
fromOrgName

Original organization name

string
toOrgId
required

Target organization ID

string
toOrgName

Target organization name

string
duration

Duration of the switch

string
reason

Reason for switching

string
switchedAt
required

When the switch was performed

string format: date-time
expiresAt

When the switch expires

string format: date-time
returnedAt

When the user returned to default tenant

string format: date-time
isActive
required

Whether the switch is currently active

boolean
Examplegenerated
{
"id": "example",
"userId": "example",
"fromOrgId": "example",
"fromOrgName": "example",
"toOrgId": "example",
"toOrgName": "example",
"duration": "example",
"reason": "example",
"switchedAt": "2026-04-15T12:00:00Z",
"expiresAt": "2026-04-15T12:00:00Z",
"returnedAt": "2026-04-15T12:00:00Z",
"isActive": true
}

Reason missing or out of range, expiresAt invalid, not later than the current expiry, or beyond the 72 h cap

No system role, or the caller is an API key (API keys cannot use tenant switches)

No open tenant switch

The switch has expired, or was ended or extended concurrently