Allows users with the impersonate:users permission (Staff and Owner roles, Owner organization only)
to impersonate another active user, without the target's consent. An Owner-role account is never a
target. The token expires after the IMPERSONATION_SESSION_DURATION of the backend (default 1 hour),
and every session is audited.
POST
/impersonate
curl \
--request POST 'https://my.nethesis.it/backend/api/impersonate' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"user_id": "jf584cz36kce"
}'
Request examples
{
"user_id": "jf584cz36kce"
}
Response examples (200)
{
"code": 200,
"message": "impersonation started successfully",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 3600,
"expires_at": "2025-09-04T14:30:00Z",
"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",
"type": "customer"
},
"roles": [
{
"id": "rol_admin_123",
"name": "Admin"
}
],
"custom_data": {
"department": "IT",
"position": "Senior Developer"
},
"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": "2026-05-04T09:42:00Z",
"suspended_at": "2026-05-04T09:42:00Z",
"created_by": {
"user_id": "aa15fcvgzw1y",
"username": "owner",
"name": "Nethesis Owner",
"email": "owner@nethesis.it",
"organization_id": "2wl3iixbc8ua",
"organization_name": "Owner",
"organization_type": "owner",
"on_behalf_of": true
},
"can_be_impersonated": true,
"has_avatar": false
},
"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",
"type": "customer"
},
"roles": [
{
"id": "rol_admin_123",
"name": "Admin"
}
],
"custom_data": {
"department": "IT",
"position": "Senior Developer"
},
"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": "2026-05-04T09:42:00Z",
"suspended_at": "2026-05-04T09:42:00Z",
"created_by": {
"user_id": "aa15fcvgzw1y",
"username": "owner",
"name": "Nethesis Owner",
"email": "owner@nethesis.it",
"organization_id": "2wl3iixbc8ua",
"organization_name": "Owner",
"organization_type": "owner",
"on_behalf_of": true
},
"can_be_impersonated": true,
"has_avatar": false
}
}
}
Response examples (400)
Cannot impersonate yourself
{
"code": 400,
"message": "Cannot impersonate yourself"
}
{
"code": 400,
"message": "Target user not found or inaccessible"
}
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": {}
}