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

# Create a durable AI chat session (bearer token)

> The bearer twin of the browser session transport - the successor the deprecated POST /api/v1/chat/general points clients at. Token authentication replaces the session cookie and CSRF pair; authorisation is the browser lane's.



## OpenAPI

````yaml https://platform.ankra.app/openapi.json post /api/v1/chat/sessions
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://platform.ankra.app
security: []
paths:
  /api/v1/chat/sessions:
    post:
      tags:
        - chat
      summary: Create a durable AI chat session (bearer token)
      description: >-
        The bearer twin of the browser session transport - the successor the
        deprecated POST /api/v1/chat/general points clients at. Token
        authentication replaces the session cookie and CSRF pair; authorisation
        is the browser lane's.
      operationId: create_ai_session_endpoint_api_v1_chat_sessions_post
      requestBody:
        content:
          application/json:
            schema:
              properties:
                agent_task_id:
                  anyOf:
                    - format: uuid
                      type: string
                    - type: 'null'
                  title: Agent Task Id
                cluster_id:
                  anyOf:
                    - format: uuid
                      type: string
                    - type: 'null'
                  title: Cluster Id
                conversation_id:
                  maxLength: 128
                  minLength: 1
                  title: Conversation Id
                  type: string
                idempotency_key:
                  anyOf:
                    - maxLength: 128
                      type: string
                    - type: 'null'
                  title: Idempotency Key
                mode:
                  default: agent
                  enum:
                    - ask
                    - agent
                    - plan
                  title: Mode
                  type: string
              required:
                - conversation_id
              title: NewSessionRequest
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema: {}
          description: >-
            The AISession document (an idempotency_key replay returns the
            existing session)
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: Bearer token missing (400) or invalid (401)
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: Cluster or agent task not found in the organisation
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: An active AI session for this idempotency key already exists
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    ContractDetailError:
      example:
        detail: Cluster not found
      properties:
        detail:
          oneOf:
            - type: string
            - additionalProperties: true
              properties: {}
              type: object
      required:
        - detail
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object

````