Get impersonation credentials for a user
curl --request GET \
--url https://your-instance.example.com/api/auth/impersonate/{userId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://your-instance.example.com/api/auth/impersonate/{userId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://your-instance.example.com/api/auth/impersonate/{userId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/auth/impersonate/{userId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/auth/impersonate/{userId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://your-instance.example.com/api/auth/impersonate/{userId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/auth/impersonate/{userId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"email": "sam.patel@acme.example",
"impersonationToken": "imp_5f7b1c2e8a1d4e0012c3b4a5e6f7a8b9c0d1e2f3a4b5c6d7e8",
"fullName": "Sam Patel",
"originalAdmin": {
"id": "5f7b1c2e8a1d4e0012c3b4a5",
"email": "admin@acme.example",
"fullName": "Acme Admin",
"organizationId": "5f7b1c2e8a1d4e0012c3b4a5",
"accessRole": "ADMIN",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1Zjdi..."
}
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}Auth
Get impersonation credentials for a user
Issue an impersonation token that lets a SUPERADMIN (or ADMIN within their own organization) sign in as the target user via /api/auth/login. Also returns the caller’s original-admin token so the impersonated session can later be exited via /api/auth/exit-impersonation.
GET
/
api
/
auth
/
impersonate
/
{userId}
Get impersonation credentials for a user
curl --request GET \
--url https://your-instance.example.com/api/auth/impersonate/{userId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://your-instance.example.com/api/auth/impersonate/{userId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://your-instance.example.com/api/auth/impersonate/{userId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/auth/impersonate/{userId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/auth/impersonate/{userId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://your-instance.example.com/api/auth/impersonate/{userId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/auth/impersonate/{userId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"email": "sam.patel@acme.example",
"impersonationToken": "imp_5f7b1c2e8a1d4e0012c3b4a5e6f7a8b9c0d1e2f3a4b5c6d7e8",
"fullName": "Sam Patel",
"originalAdmin": {
"id": "5f7b1c2e8a1d4e0012c3b4a5",
"email": "admin@acme.example",
"fullName": "Acme Admin",
"organizationId": "5f7b1c2e8a1d4e0012c3b4a5",
"accessRole": "ADMIN",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1Zjdi..."
}
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Response
Impersonation credentials returned
Original admin payload returned alongside an impersonation token so the SPA can later restore the admin session via /api/auth/exit-impersonation.
Show child attributes
Show child attributes
Example:
{
"id": "5f7b1c2e8a1d4e0012c3b4a5",
"email": "admin@acme.example",
"fullName": "Acme Admin",
"organizationId": "5f7b1c2e8a1d4e0012c3b4a5",
"accessRole": "ADMIN",
"conversationOpenPreference": "split",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1Zjdi..."
}