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

# Exchange cloud provider authorization code for admin session

> Verifies an authorization code/JWT from from Insforge Cloud platform and issues an internal admin session token with project_admin role



## OpenAPI

````yaml https://raw.githubusercontent.com/InsForge/InsForge/main/openapi/auth.yaml post /api/auth/admin/sessions/exchange
openapi: 3.0.3
info:
  title: Insforge Authentication API
  version: 2.0.0
  description: Authentication endpoints with separated auth and profile tables
servers: []
security: []
paths:
  /api/auth/admin/sessions/exchange:
    post:
      tags:
        - Admin
      summary: Exchange cloud provider authorization code for admin session
      description: >-
        Verifies an authorization code/JWT from from Insforge Cloud platform and
        issues an internal admin session token with project_admin role
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - code
              properties:
                code:
                  type: string
                  description: Authorization code or JWT from the Insforge
                  example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
      responses:
        '200':
          description: Cloud authorization verified, admin session created
          content:
            application/json:
              schema:
                type: object
                properties:
                  projectAdmin:
                    $ref: '#/components/schemas/ProjectAdminResponse'
                  accessToken:
                    type: string
                    description: Internal JWT for admin authentication
                  csrfToken:
                    type: string
                    description: CSRF token for `/api/auth/admin/refresh`
        '400':
          description: Invalid authorization code or JWT verification failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ProjectAdminResponse:
      type: object
      required:
        - subject
        - username
      properties:
        subject:
          type: string
          example: local:admin
        username:
          type: string
          example: admin
    ErrorResponse:
      type: object
      required:
        - error
        - message
        - statusCode
      properties:
        error:
          type: string
          description: Error code for programmatic handling
          example: VALIDATION_ERROR
        message:
          type: string
          description: Human-readable error message
          example: Email is already in use
        statusCode:
          type: integer
          description: HTTP status code
          example: 400
        nextActions:
          type: string
          description: Suggested action to resolve the error
          example: Please use a different email address

````