/impersonate - Start impersonation (permission-based access)
Allows users with impersonate:users
permission (Super Admin role) or Owner organization role
to impersonate another user, but only if that user has active consent enabled.
The impersonation token duration will match the user's consent settings.
POST
/impersonate
curl \
--request POST 'https://api.your-domain.com/api/impersonate' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"user_id":"user-uuid-here"}'
Request examples
{
"user_id": "user-uuid-here"
}
Response examples (200)
{
"code": 200,
"message": "impersonation started successfully",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 86400,
"session_id": "session-uuid-here",
"is_impersonating": true,
"impersonated_user": {
"id": "usr_123456789",
"logto_id": "user_abc123def456",
"username": "john.doe",
"email": "john@example.com",
"name": "John Doe",
"phone": "+39 333 123456",
"organization": {
"id": "12345678-1234-1234-1234-123456789abc",
"logto_id": "org_123456789",
"name": "ACME Corp"
},
"roles": [
{
"id": "rol_admin_123",
"name": "Admin"
}
],
"custom_data": {
"position": "Senior Developer",
"department": "IT"
},
"created_at": "2025-06-20T14:30:00Z",
"updated_at": "2025-06-21T10:45:00Z",
"logto_synced_at": "2025-06-21T10:45:00Z",
"latest_login_at": "2025-06-21T15:30:45Z",
"deleted_at": "2025-05-04T09:42:00Z",
"suspended_at": "2025-05-04T09:42:00Z",
"can_be_impersonated": true
},
"impersonator": {
"id": "usr_123456789",
"logto_id": "user_abc123def456",
"username": "john.doe",
"email": "john@example.com",
"name": "John Doe",
"phone": "+39 333 123456",
"organization": {
"id": "12345678-1234-1234-1234-123456789abc",
"logto_id": "org_123456789",
"name": "ACME Corp"
},
"roles": [
{
"id": "rol_admin_123",
"name": "Admin"
}
],
"custom_data": {
"position": "Senior Developer",
"department": "IT"
},
"created_at": "2025-06-20T14:30:00Z",
"updated_at": "2025-06-21T10:45:00Z",
"logto_synced_at": "2025-06-21T10:45:00Z",
"latest_login_at": "2025-06-21T15:30:45Z",
"deleted_at": "2025-05-04T09:42:00Z",
"suspended_at": "2025-05-04T09:42:00Z",
"can_be_impersonated": true
}
}
}
Response examples (400)
Cannot impersonate yourself
{
"code": 400,
"message": "Cannot impersonate yourself"
}
{
"code": 400,
"message": "Target user not found or inaccessible"
}
{
"code": 400,
"message": "Target user has not provided consent for impersonation or consent has expired"
}
Response examples (403)
User without impersonation permissions attempted impersonation
{
"code": 403,
"message": "Insufficient permissions to impersonate users"
}
{
"code": 403,
"message": "Cannot impersonate while already impersonating another user. Exit current impersonation first."
}
Response examples (401)
{
"code": 401,
"message": "invalid token",
"data": {}
}