Mint an impersonation token
const url = 'https://api.torii.so/api/server/v1/users/01931a73-8b00-7000-8000-000000000000/impersonation-token';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"actorUserId":"01931a73-8b00-7000-8000-000000000000","reason":"Investigating support ticket #4821","redirectUrl":"https://app.example.com/dashboard","expiresInSeconds":600}'};
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.torii.so/api/server/v1/users/01931a73-8b00-7000-8000-000000000000/impersonation-token \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "actorUserId": "01931a73-8b00-7000-8000-000000000000", "reason": "Investigating support ticket #4821", "redirectUrl": "https://app.example.com/dashboard", "expiresInSeconds": 600 }'Creates a single-use, short-lived impersonation token for the target user, attributed to actorUserId. Redeem it programmatically via POST /_torii/auth/session/impersonate (access token in the body), or hand the returned url to an operator to open in a browser (establishes the session and redirects to the landing URL). Counts against the same per-period impersonation quota and usage ledger as the dashboard.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”The user to impersonate.
Example
01931a73-8b00-7000-8000-000000000000Request Body required
Section titled “Request Body required ”Body for minting an impersonation token.
object
The principal the impersonation is on behalf of (recorded for accountability). Must be a user in this environment.
Example
01931a73-8b00-7000-8000-000000000000Mandatory justification (GDPR purpose limitation); recorded in the audit log on mint and redeem.
Example
Investigating support ticket #4821Optional post-redeem landing URL for the url redeem link; its origin must be in the environment’s allowed origins. Omit to default to the environment’s first non-wildcard allowed origin.
Example
https://app.example.com/dashboardOptional token lifetime in seconds, 60..600. Omit for the 600s default.
Example
600Responses
Section titled “ Responses ”The minted token, its lifetime, and (when a landing URL resolves) a ready-to-use redeem URL.
A minted impersonation token.
object
The single-use token. Redeem via POST /_torii/auth/session/impersonate, or hand the ready-to-use url to an operator.
The token’s lifetime in seconds (the resolved value after any override).
A ready-to-use, navigable redeem link on the environment’s Frontend API host. Opening it in a browser establishes the impersonated session and redirects to the landing URL. Backed by the same single-use token. Null when no landing URL could be resolved (no redirectUrl given and the environment has no concrete allowed origin) — redeem the token via POST instead.
Example
{ "expiresInSeconds": 600, "url": "https://auth.example.com/_torii/auth/session/impersonate?token=…"}Deleted target, expiresInSeconds out of the 60..600 range, or redirectUrl missing/malformed/not in the environment’s allowed origins.
object
object
Example generated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "instance": "https://example.com", "properties": { "additionalProperty": "example" }}Missing or invalid secret key.
object
object
Example generated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "instance": "https://example.com", "properties": { "additionalProperty": "example" }}Plan does not include impersonation, or the per-period quota is exhausted.
object
object
Example generated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "instance": "https://example.com", "properties": { "additionalProperty": "example" }}Target or actor is in another environment, or impersonation is disabled for this environment.
object
object
Example generated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "instance": "https://example.com", "properties": { "additionalProperty": "example" }}