/impersonate - Exit impersonation mode

DELETE /impersonate

Allows user to exit impersonation mode and return to their original account. This endpoint can only be called with an active impersonation token. Returns fresh tokens for the original user and completes the audit session.

Responses

  • 200 application/json

    Impersonation ended successfully

    Hide response attributes Show response attributes object
    • code integer
    • message string
    • data object
      Hide data attributes Show data attributes object
      • token string

        New JWT token for original user (24-hour expiration)

      • refresh_token string

        New refresh token for original user

      • expires_in integer

        Token expiration time in seconds (86400 = 24 hours)

  • 400 application/json

    Bad request (not currently impersonating)

    Hide response attributes Show response attributes object
    • code integer

      HTTP error code

    • message string

      Error message

    • data object
      Hide data attributes Show data attributes object
      • type string

        Type of error

        Values are validation_error or external_api_error.

      • errors array[object]
        Hide errors attributes Show errors attributes object
        • key string

          Field name that failed validation

        • message string

          Error code or message

        • value string

          Value that failed validation

      • details

        Additional error details

  • 401 application/json

    Unauthorized - invalid or missing token

    Hide response attributes Show response attributes object
    • code integer
    • message string
    • data object | null
DELETE /impersonate
curl \
 --request DELETE 'https://api.your-domain.com/api/impersonate' \
 --header "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
{
  "code": 200,
  "message": "impersonation ended successfully",
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "expires_in": 86400
  }
}
Response examples (400)
{
  "code": 400,
  "message": "Not currently impersonating a user"
}
Response examples (401)
{
  "code": 401,
  "message": "invalid token",
  "data": {}
}