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

# Get session message history

> Get conversation history for a chat session. Returns all messages in chronological order.

Example use case: A customer support session where the user asks multiple questions about a product.




## OpenAPI

````yaml /openapi.yaml get /v1/chat/sessions/{id}/messages
openapi: 3.1.0
info:
  title: Co-mind.ai Private AI Platform API
  version: 1.2.4
  description: >
    Co-mind.ai Private AI Platform API.


    ## Features

    - OpenAI-compatible endpoints

    - Tool/function calling support

    - Streaming responses

    - Multiple backend support

    - Personal Access Tokens (PAT) for programmatic access


    ## Authentication

    The API supports two authentication methods:


    **1. JWT Authentication** — Login with email/password to get short-lived
    access tokens.

    Use for interactive sessions (web apps, Postman).


    **2. Personal Access Tokens (PAT)** — Long-lived tokens for programmatic/API
    access.

    Create via `POST /v1/api-tokens` after authenticating with JWT.

    PAT format: `cmnd_<tokenId>.<secret>`


    Both methods use the `Authorization: Bearer <token>` header.
  contact:
    email: support@co-mind.ai
servers:
  - url: http://co-mind-platform-host
    description: Co-mind.ai AI Platform
security:
  - BearerAuth: []
tags:
  - name: Public
    description: Public endpoints (no authentication required)
  - name: Authentication
    description: JWT login, refresh, logout, and user info
  - name: API Tokens
    description: Personal Access Token (PAT) management
  - name: Chat
    description: OpenAI-compatible chat completions
  - name: Knowledge Base
    description: Knowledge base management and RAG-enhanced chat
  - name: Completions
    description: Text completion endpoints
  - name: Embeddings
    description: Text embedding generation
  - name: Discovery
    description: Model and backend discovery endpoints
  - name: Echo Engine
    description: Audio transcription (STT), health, and metrics
  - name: Echo Engine - Recordings
    description: Recording CRUD and job linking
  - name: Echo Engine - TTS
    description: Text-to-speech synthesis
  - name: Sanitizer Admin
    description: Security policy management, health, and testing
  - name: Document Analyzer
    description: Document analysis, extraction, and review workflows
  - name: Researcher
    description: Web search, research sessions, analysis, and synthesis
  - name: Directory Admin
    description: LDAP/AD identity provider configuration and sync
  - name: Entra Admin
    description: Microsoft Entra ID (Azure AD) configuration
  - name: Tenant Admin
    description: Tenant/organization management
  - name: Tenant API Keys
    description: Provider API key management per tenant
  - name: Sub-org Management
    description: Sub-organization management
  - name: Service Endpoints
    description: SSO config discovery, OAuth token exchange
  - name: Audit Logs
    description: Audit log querying and aggregation
  - name: Quota
    description: Usage quota tracking
paths:
  /v1/chat/sessions/{id}/messages:
    get:
      tags:
        - Chat
      summary: Get session message history
      description: >
        Get conversation history for a chat session. Returns all messages in
        chronological order.


        Example use case: A customer support session where the user asks
        multiple questions about a product.
      operationId: getSessionMessages
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: The session ID
          example: session_xyz789
        - name: limit
          in: query
          schema:
            type: integer
            default: 50
          description: Maximum number of messages to return
        - name: before
          in: query
          schema:
            type: string
          description: Message ID to paginate before
        - name: after
          in: query
          schema:
            type: string
          description: Message ID to paginate after
      responses:
        '200':
          description: Message history
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatSessionMessageList'
              examples:
                multi_turn_conversation:
                  summary: Multi-turn conversation with 6 messages
                  value:
                    object: list
                    data:
                      - id: msg_001
                        object: chat.message
                        session_id: session_xyz789
                        role: user
                        content: What are the main features of your product?
                        created_at: 1699564800
                      - id: msg_002
                        object: chat.message
                        session_id: session_xyz789
                        role: assistant
                        content: >-
                          Our product has three main features - advanced
                          analytics, real-time collaboration, and automated
                          workflows.
                        created_at: 1699564801
                        knowledge_base_context:
                          sources:
                            - knowledgebase_id: kb_abc123
                              document_id: doc_123
                              title: Product Overview
                              relevance_score: 0.95
                              page: 2
                      - id: msg_003
                        object: chat.message
                        session_id: session_xyz789
                        role: user
                        content: Can you tell me more about the analytics feature?
                        created_at: 1699564820
                      - id: msg_004
                        object: chat.message
                        session_id: session_xyz789
                        role: assistant
                        content: >-
                          The analytics feature provides real-time dashboards,
                          custom reports, and predictive insights using machine
                          learning algorithms.
                        created_at: 1699564821
                        knowledge_base_context:
                          sources:
                            - knowledgebase_id: kb_abc123
                              document_id: doc_456
                              title: Analytics Documentation
                              relevance_score: 0.92
                              page: 5
                      - id: msg_005
                        object: chat.message
                        session_id: session_xyz789
                        role: user
                        content: What machine learning algorithms do you support?
                        created_at: 1699564840
                      - id: msg_006
                        object: chat.message
                        session_id: session_xyz789
                        role: assistant
                        content: >-
                          We support several ML algorithms including linear
                          regression, decision trees, random forests, gradient
                          boosting, and neural networks for deep learning tasks.
                        created_at: 1699564841
                    has_more: false
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    ChatSessionMessageList:
      type: object
      properties:
        object:
          type: string
          example: list
        data:
          type: array
          items:
            $ref: '#/components/schemas/ChatSessionMessage'
        has_more:
          type: boolean
          example: false
      example:
        object: list
        data:
          - id: msg_001
            object: chat.message
            session_id: session_xyz789
            role: user
            content: What are the main features of your product?
            created_at: 1699564800
          - id: msg_002
            object: chat.message
            session_id: session_xyz789
            role: assistant
            content: >-
              Our product has three main features - advanced analytics,
              real-time collaboration, and automated workflows.
            created_at: 1699564801
            knowledge_base_context:
              sources:
                - knowledgebase_id: kb_abc123
                  document_id: doc_123
                  title: Product Overview
                  relevance_score: 0.95
                  page: 2
          - id: msg_003
            object: chat.message
            session_id: session_xyz789
            role: user
            content: Can you tell me more about the analytics feature?
            created_at: 1699564820
          - id: msg_004
            object: chat.message
            session_id: session_xyz789
            role: assistant
            content: >-
              The analytics feature provides real-time dashboards, custom
              reports, and predictive insights using machine learning
              algorithms.
            created_at: 1699564821
            knowledge_base_context:
              sources:
                - knowledgebase_id: kb_abc123
                  document_id: doc_456
                  title: Analytics Documentation
                  relevance_score: 0.92
                  page: 5
          - id: msg_005
            object: chat.message
            session_id: session_xyz789
            role: user
            content: What machine learning algorithms do you support?
            created_at: 1699564840
          - id: msg_006
            object: chat.message
            session_id: session_xyz789
            role: assistant
            content: >-
              We support several ML algorithms including linear regression,
              decision trees, random forests, gradient boosting, and neural
              networks for deep learning tasks.
            created_at: 1699564841
        has_more: false
    ChatSessionMessage:
      type: object
      properties:
        id:
          type: string
          example: msg_abc123
        object:
          type: string
          example: chat.message
        session_id:
          type: string
          example: session_xyz789
        role:
          type: string
          enum:
            - user
            - assistant
            - system
          example: assistant
        content:
          type: string
          example: The main features include...
        created_at:
          type: integer
          description: Unix timestamp
          example: 1699564800
        knowledge_base_context:
          type: object
          properties:
            sources:
              type: array
              items:
                type: object
                properties:
                  knowledgebase_id:
                    type: string
                  document_id:
                    type: string
                  title:
                    type: string
                  content:
                    type: string
                  page:
                    type: integer
                  relevance_score:
                    type: number
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
  responses:
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT or PAT
      description: >
        Bearer token authentication. Supports two token types:

        - **JWT Access Token** — obtained via `POST /v1/auth/login`

        - **Personal Access Token (PAT)** — created via `POST /v1/api-tokens`,
        format: `cmnd_<tokenId>.<secret>`

````