Impersonate a user

Start a session as one of your users, in one of their apps.

POST /organizations/{org}/impersonate

Returns a URL that signs you into an app as the given user, in the given tenant, so you see what they see. The URL carries a one-time authorization code, so the response is served Cache-Control: no-store.

Authorization

Org owner. Anyone else gets 403 forbidden.

Path parameters

NameTypeDescription
orgstringThe organization: its id (org_…) or its slug. It has to be an org your token can manage (see Who can call it)

Body

FieldTypeRequiredDescription
user_idstringyesThe user to become, usr_…
tenant_idstringyesThe tenant to enter as, tnt_…
client_idstringyesThe app to enter, cli_…

No other field is accepted.

Response

201 Created Open redirect_url to enter the app.

{ "redirect_url": "https://…" }

Errors

StatuserrorWhen
400invalid_requestAn unknown field, or an id that is missing or of the wrong kind
403forbiddenYou are not an owner of the org
404not_foundThe user is not in that tenant, or the org is not yours
422unprocessableThat client cannot receive an impersonated session

Example

curl -X POST https://loginwith.loginwith.dev/organizations/acme/impersonate \
  -H "Authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"user_id": "usr_65f1c2a9e4b0d3f7a1c8e909", "tenant_id": "tnt_65f1c2a9e4b0d3f7a1c8e908", "client_id": "cli_65f1c2a9e4b0d3f7a1c8e902"}'