Switch the session to another company
const url = 'https://api.emite.cr/v1/auth/switch-tenant';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"tenantId":"01a00c73-5c09-7bb5-8b9e-d91c43bd61dc"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.emite.cr/v1/auth/switch-tenant \ --header 'Content-Type: application/json' \ --data '{ "tenantId": "01a00c73-5c09-7bb5-8b9e-d91c43bd61dc" }'Re-issues this session for another company the person is a member of. The new token keeps the original sign-in time, so it expires no later than the one it replaces, and follows the destination company’s session rules. It is returned in the body and in the X-Session-Token header. 403 TENANT_REQUIRES_REAUTH (params.reason: tenant_policy or sessions_revoked) when that company’s rules no longer admit this sign-in — its maximum session ran out, or an admin closed this member’s sessions for it: only signing in again enters it. The current session is not affected.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Id of the company to switch to, one of memberships in GET /v1/auth/me. The person must be a member of it: 403 NOT_A_MEMBER otherwise.
Example
01a00c73-5c09-7bb5-8b9e-d91c43bd61dcResponses
Section titled “Responses”The session, re-issued for the destination company.
object
The session token, a signed JWT: send it as Authorization: Bearer <accessToken>. It acts for the person, in the company it names when it names one (currentTenantId in GET /v1/auth/me). The same token comes in the X-Session-Token response header.
Always Bearer: the scheme to send the token with in the Authorization header.
Remaining life of this token: whole seconds followed by s ("28800s" = 8 hours). It never reaches past the maximum of the session, which counts from the sign-in, so a re-issued token (switching company, renewing) lives less. Under a company inactivity rule it also ends that many minutes after it was issued, unless it is renewed with POST /v1/auth/sessions/renew.
The instant this token expires (ISO 8601, UTC): expiresIn as a date.
Present, and true, only in the answer of POST /v1/auth/login, when the password that just signed in does not meet the rule a new password must meet today (12 to 72 characters, nothing of the person, hard to guess: see POST /v1/auth/signup). A suggestion to change it, never a refusal: the sign-in went through.
Example
{ "tokenType": "Bearer", "expiresIn": "28800s", "expiresAt": "2026-10-22T22:30:00.000Z", "passwordChangeSuggested": true}