Skip to content

Get current tenant context

GET
/api/v1/tenant/context
curl --request GET \
--url http://localhost:3000/api/v1/tenant/context \
--header 'Authorization: Bearer <token>'
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
isSwitched
required

Whether user is currently switched to another tenant

boolean
originalOrgId

Original organization ID (if switched)

string
originalOrgName

Original organization name (if switched)

string
currentOrgId
required

Current organization ID

string
currentOrgName

Current organization name

string
currentOrgSlug

Current organization slug

string
originalOrgSlug

Original organization slug (if switched)

string
activeSwitch

Active switch details (if switched)

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
expiresAt

When the switch expires (if switched)

string format: date-time
currentRole

The caller’s role in the current organization, from the database: admin, operator, viewer, a custom role name, support, or superadmin. Null when unresolved.

string
nullable
permissions

The caller’s effective permissions in the current organization, as the server enforces them.

Array<string>
Examplegenerated
{
"isSwitched": true,
"originalOrgId": "example",
"originalOrgName": "example",
"currentOrgId": "example",
"currentOrgName": "example",
"currentOrgSlug": "example",
"originalOrgSlug": "example",
"activeSwitch": {
"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
},
"expiresAt": "2026-04-15T12:00:00Z",
"currentRole": "example",
"permissions": [
"example"
]
}

Forbidden. The caller lacks the permission, is an API key (API keys cannot use tenant switches), or is not a member of the organization named by x-organization-id. This endpoint is a global operation, so it never returns TENANT_SWITCH_REQUIRED.