Start an admin-impersonation session for a target user
POST /admin/users/{ref}/impersonate
Issues a NEW session bound to the target user but attributed to the calling admin via sessions.impersonated_by_user_ref. Sets the session cookie on the response so the very next request runs under the target’s identity. The admin’s prior session is NOT revoked — ending impersonation issues a fresh admin session via /auth/impersonation/end.
Gated on auth.impersonate (admin-only by seed).
Refusals (defense-in-depth):
- 400 — self-impersonation (admin impersonating themself).
- 400 — chain attempt (admin tries to impersonate while already impersonating).
- 403 — target holds
system.admin(no privilege- escalation by chaining; admins must coordinate out-of-band to impersonate each other). - 404 — target user not found.
Audit emits admin.impersonation.started with subject = target, actor = admin, metadata.session_id + reason.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Request Body
Section titled “Request Body ”object
Admin-supplied justification (ticket number, brief context). Recorded in the impersonation.started audit event. Encouraged but not required.
Responses
Section titled “ Responses ”Impersonation session minted + cookie set.
Returned by POST /admin/users/{ref}/impersonate when the impersonation session has been minted + the cookie set. The frontend uses this to render the persistent “you are acting as @target” banner without an immediate reload.
object
The newly-minted impersonation session’s id.
When the impersonation session hard-expires (default 30 min from start). The admin can end earlier via the “End impersonation” button.
Malformed request
object
Human-readable error summary
Example
the request could not be completedAuthentication required, missing, or invalid
object
Human-readable error summary
Example
the request could not be completedExample
{ "error": "authentication required: sign in and retry with a valid session or API token"}Authenticated but missing required capabilities
object
Human-readable error summary
Example
the request could not be completedResource not found
object
Human-readable error summary
Example
the request could not be completed