> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tetherai.ca/llms.txt
> Use this file to discover all available pages before exploring further.

# Exit impersonation and restore original admin session

> Verify the supplied original-admin token (captured at impersonation start) and return it so the client can restore the admin session. Only callable from a session whose token carries the isImpersonation flag.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/auth/exit-impersonation
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/auth/exit-impersonation:
    post:
      tags:
        - Auth
      summary: Exit impersonation and restore original admin session
      description: >-
        Verify the supplied original-admin token (captured at impersonation
        start) and return it so the client can restore the admin session. Only
        callable from a session whose token carries the isImpersonation flag.
      operationId: post_auth_exit_impersonation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthExitImpersonationRequest'
      responses:
        '200':
          description: Impersonation exited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthExitImpersonationResponse'
        '400':
          description: Not in impersonation mode or missing original admin credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorResponse'
        '401':
          description: Invalid original admin token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    AuthExitImpersonationRequest:
      type: object
      properties:
        originalAdminToken:
          type: string
          description: >-
            Original admin JWT captured at impersonation start; re-verified
            server-side and must resolve to a SUPERADMIN/ADMIN role matching
            `originalAdminUser`.
        originalAdminUser:
          type: object
          additionalProperties: true
          description: >-
            Original admin payload (id, email, …) captured at impersonation
            start. Its `id`/`email` must match the verified `originalAdminToken`
            payload — guards against tampering.
      required:
        - originalAdminToken
        - originalAdminUser
      additionalProperties: false
      example:
        originalAdminToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1Zjdi...
        originalAdminUser:
          id: 5f7b1c2e8a1d4e0012c3b4a5
          email: admin@acme.example
          fullName: Acme Admin
          organizationId: 5f7b1c2e8a1d4e0012c3b4a5
          accessRole: ADMIN
    AuthExitImpersonationResponse:
      type: object
      description: >-
        Returned by `/api/auth/exit-impersonation` after the original admin
        session is restored.
      properties:
        token:
          type: string
          description: Original-admin access token to swap back into.
        user:
          $ref: '#/components/schemas/AuthUserSummary'
        message:
          type: string
      required:
        - token
        - user
        - message
      additionalProperties: true
      example:
        token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        user:
          id: 5f7b1c2e8a1d4e0012c3b4a5
          email: admin@acme.example
          organizationId: 64a1b2c3d4e5f60012345678
          accessRole: ADMIN
        message: Impersonation exited successfully
    AuthErrorResponse:
      type: object
      description: >-
        Generic error envelope returned by Auth endpoints. Most paths include
        only `error`; a few add `details`/`code` for diagnostic context.
      properties:
        error:
          type: string
        details:
          type: string
        code:
          type: string
      required:
        - error
      additionalProperties: true
      example:
        error: Invalid or expired token
        code: TOKEN_EXPIRED
    AuthUserSummary:
      type: object
      description: Compact User payload returned with auth tokens.
      properties:
        id:
          type: string
        email:
          type: string
          format: email
        fullName:
          type: string
        organizationId:
          type: string
        workosOrganizationId:
          type: string
        accessRole:
          type: string
        departmentId:
          type: string
        workosUserId:
          type: string
        conversationOpenPreference:
          type: string
      required:
        - id
        - email
        - organizationId
        - accessRole
      additionalProperties: true
      example:
        id: 5f7b1c2e8a1d4e0012c3b4a5
        email: admin@acme.example
        fullName: Acme Admin
        organizationId: 64a1b2c3d4e5f60012345678
        accessRole: ADMIN
        conversationOpenPreference: split
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````