/impersonate/status - Check current impersonation status
Checks if the current user has an active impersonation session.
Works with both token types:
- Impersonation token: Returns session details from the token
- Regular token: Checks Redis for active session and returns a new impersonation token if found
Use case for regular token:
After a page refresh, the frontend loses the impersonation token but calls /auth/exchange
to get a regular token. This endpoint allows the frontend to check if there's an active
impersonation session and receive a new impersonation token to continue the session.
Response when impersonating:
is_impersonating
: truetoken
: New impersonation JWT token (with remaining duration)expires_in
: Remaining seconds until expirationsession_id
: Session ID for audit trackingimpersonated_user
: Details of the user being impersonatedimpersonator
: Details of the user doing the impersonationexpires_at
: Session expiration timestampcreated_at
: Session creation timestamp
Response when not impersonating:
is_impersonating
: false
GET
/impersonate/status
curl \
--request GET 'https://api.your-domain.com/api/impersonate/status' \
--header "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
Currently impersonating
{
"code": 200,
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"created_at": "2025-09-29T16:33:59Z",
"expires_at": "2025-09-29T17:33:59Z",
"expires_in": 3540,
"session_id": "d7734c1e-bed3-4350-8992-a5e09d4d253f",
"impersonator": {
"id": "c5054f56-3005-43c2-a237-07aa44e1551c",
"name": "Company Owner",
"email": "owner@example.com",
"org_role": "Owner",
"username": "owner"
},
"is_impersonating": true,
"impersonated_user": {
"id": "d1e17b87-11ce-4e74-a9f8-34d9638135f1",
"name": "Edoardo Support",
"email": "edoardo.spadoni@nethesis.it",
"org_role": "Reseller",
"username": "edoardo_spadoni"
}
},
"message": "currently impersonating"
}
{
"code": 200,
"data": {
"is_impersonating": false
},
"message": "not currently impersonating"
}
Response examples (401)
{
"code": 401,
"message": "invalid token",
"data": {}
}
Response examples (500)
Failed to check for active session
{
"code": 500,
"message": "failed to check impersonation status"
}
{
"code": 500,
"message": "failed to generate impersonation token"
}