> ## Documentation Index
> Fetch the complete documentation index at: https://cognitio-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get message

> Retrieve a specific message from a session by its message ID.



## OpenAPI

````yaml /openapi.json get /session/{sessionID}/message/{messageID}
openapi: 3.1.1
info:
  title: cognitio
  description: cognitio api
  version: 1.0.0
servers: []
security: []
paths:
  /session/{sessionID}/message/{messageID}:
    get:
      summary: Get message
      description: Retrieve a specific message from a session by its message ID.
      operationId: session.message
      parameters:
        - in: query
          name: directory
          schema:
            type: string
        - in: query
          name: workspace
          schema:
            type: string
        - in: path
          name: sessionID
          schema:
            type: string
            pattern: ^ses.*
          required: true
        - in: path
          name: messageID
          schema:
            type: string
            pattern: ^msg.*
          required: true
      responses:
        '200':
          description: Message
          content:
            application/json:
              schema:
                type: object
                properties:
                  info:
                    $ref: '#/components/schemas/Message'
                  parts:
                    type: array
                    items:
                      $ref: '#/components/schemas/Part'
                required:
                  - info
                  - parts
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestError'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
      x-codeSamples:
        - lang: js
          source: |-
            import { createCognitioClient } from "@cognitio/sdk

            const client = createCognitioClient()
            await client.session.message({
              ...
            })
components:
  schemas:
    Message:
      anyOf:
        - $ref: '#/components/schemas/UserMessage'
        - $ref: '#/components/schemas/AssistantMessage'
    Part:
      anyOf:
        - $ref: '#/components/schemas/TextPart'
        - $ref: '#/components/schemas/SubtaskPart'
        - $ref: '#/components/schemas/ReasoningPart'
        - $ref: '#/components/schemas/FilePart'
        - $ref: '#/components/schemas/ToolPart'
        - $ref: '#/components/schemas/StepStartPart'
        - $ref: '#/components/schemas/StepFinishPart'
        - $ref: '#/components/schemas/SnapshotPart'
        - $ref: '#/components/schemas/PatchPart'
        - $ref: '#/components/schemas/AgentPart'
        - $ref: '#/components/schemas/RetryPart'
        - $ref: '#/components/schemas/CompactionPart'
    BadRequestError:
      type: object
      properties:
        data: {}
        errors:
          type: array
          items:
            type: object
            propertyNames:
              type: string
            additionalProperties: {}
        success:
          type: boolean
          const: false
      required:
        - data
        - errors
        - success
    NotFoundError:
      type: object
      properties:
        name:
          type: string
          const: NotFoundError
        data:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - name
        - data
    UserMessage:
      type: object
      properties:
        id:
          type: string
          pattern: ^msg.*
        sessionID:
          type: string
          pattern: ^ses.*
        role:
          type: string
          const: user
        time:
          type: object
          properties:
            created:
              type: number
          required:
            - created
        parentMessageID:
          type: string
          pattern: ^msg.*
        format:
          $ref: '#/components/schemas/OutputFormat'
        summary:
          type: object
          properties:
            title:
              type: string
            body:
              type: string
            diffs:
              type: array
              items:
                $ref: '#/components/schemas/SnapshotFileDiff'
          required:
            - diffs
        agent:
          type: string
        model:
          type: object
          properties:
            providerID:
              type: string
            modelID:
              type: string
            variant:
              type: string
          required:
            - providerID
            - modelID
        system:
          type: string
        tools:
          type: object
          propertyNames:
            type: string
          additionalProperties:
            type: boolean
      required:
        - id
        - sessionID
        - role
        - time
        - agent
        - model
    AssistantMessage:
      type: object
      properties:
        id:
          type: string
          pattern: ^msg.*
        sessionID:
          type: string
          pattern: ^ses.*
        role:
          type: string
          const: assistant
        time:
          type: object
          properties:
            created:
              type: number
            completed:
              type: number
          required:
            - created
        error:
          anyOf:
            - $ref: '#/components/schemas/ProviderAuthError'
            - $ref: '#/components/schemas/UnknownError'
            - $ref: '#/components/schemas/MessageOutputLengthError'
            - $ref: '#/components/schemas/MessageAbortedError'
            - $ref: '#/components/schemas/StructuredOutputError'
            - $ref: '#/components/schemas/ContextOverflowError'
            - $ref: '#/components/schemas/APIError'
        parentID:
          type: string
          pattern: ^msg.*
        parentMessageID:
          type: string
          pattern: ^msg.*
        modelID:
          type: string
        providerID:
          type: string
        mode:
          type: string
        agent:
          type: string
        path:
          type: object
          properties:
            cwd:
              type: string
            root:
              type: string
          required:
            - cwd
            - root
        summary:
          type: boolean
        cost:
          type: number
        tokens:
          type: object
          properties:
            total:
              type: number
            input:
              type: number
            output:
              type: number
            reasoning:
              type: number
            cache:
              type: object
              properties:
                read:
                  type: number
                write:
                  type: number
              required:
                - read
                - write
          required:
            - input
            - output
            - reasoning
            - cache
        structured: {}
        variant:
          type: string
        finish:
          type: string
      required:
        - id
        - sessionID
        - role
        - time
        - parentID
        - modelID
        - providerID
        - mode
        - agent
        - path
        - cost
        - tokens
    TextPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: text
        text:
          type: string
        synthetic:
          type: boolean
        ignored:
          type: boolean
        time:
          type: object
          properties:
            start:
              type: number
            end:
              type: number
          required:
            - start
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - id
        - sessionID
        - messageID
        - type
        - text
    SubtaskPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: subtask
        prompt:
          type: string
        description:
          type: string
        agent:
          type: string
        model:
          type: object
          properties:
            providerID:
              type: string
            modelID:
              type: string
          required:
            - providerID
            - modelID
        spawnMode:
          type: string
          enum:
            - fresh
            - inherit
        command:
          type: string
      required:
        - id
        - sessionID
        - messageID
        - type
        - prompt
        - description
        - agent
    ReasoningPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: reasoning
        text:
          type: string
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        time:
          type: object
          properties:
            start:
              type: number
            end:
              type: number
          required:
            - start
      required:
        - id
        - sessionID
        - messageID
        - type
        - text
        - time
    FilePart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: file
        mime:
          type: string
        filename:
          type: string
        url:
          type: string
        source:
          $ref: '#/components/schemas/FilePartSource'
      required:
        - id
        - sessionID
        - messageID
        - type
        - mime
        - url
    ToolPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: tool
        callID:
          type: string
        tool:
          type: string
        state:
          $ref: '#/components/schemas/ToolState'
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - id
        - sessionID
        - messageID
        - type
        - callID
        - tool
        - state
    StepStartPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: step-start
        snapshot:
          type: string
      required:
        - id
        - sessionID
        - messageID
        - type
    StepFinishPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: step-finish
        reason:
          type: string
        snapshot:
          type: string
        cost:
          type: number
        tokens:
          type: object
          properties:
            total:
              type: number
            input:
              type: number
            output:
              type: number
            reasoning:
              type: number
            cache:
              type: object
              properties:
                read:
                  type: number
                write:
                  type: number
              required:
                - read
                - write
          required:
            - input
            - output
            - reasoning
            - cache
      required:
        - id
        - sessionID
        - messageID
        - type
        - reason
        - cost
        - tokens
    SnapshotPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: snapshot
        snapshot:
          type: string
      required:
        - id
        - sessionID
        - messageID
        - type
        - snapshot
    PatchPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: patch
        hash:
          type: string
        files:
          type: array
          items:
            type: string
      required:
        - id
        - sessionID
        - messageID
        - type
        - hash
        - files
    AgentPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: agent
        name:
          type: string
        source:
          type: object
          properties:
            value:
              type: string
            start:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            end:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
          required:
            - value
            - start
            - end
      required:
        - id
        - sessionID
        - messageID
        - type
        - name
    RetryPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: retry
        attempt:
          type: number
        error:
          $ref: '#/components/schemas/APIError'
        time:
          type: object
          properties:
            created:
              type: number
          required:
            - created
      required:
        - id
        - sessionID
        - messageID
        - type
        - attempt
        - error
        - time
    CompactionPart:
      type: object
      properties:
        id:
          type: string
          pattern: ^prt.*
        sessionID:
          type: string
          pattern: ^ses.*
        messageID:
          type: string
          pattern: ^msg.*
        type:
          type: string
          const: compaction
        auto:
          type: boolean
        overflow:
          type: boolean
        tail_start_id:
          type: string
          pattern: ^msg.*
        customInstructions:
          type: string
      required:
        - id
        - sessionID
        - messageID
        - type
        - auto
    OutputFormat:
      anyOf:
        - $ref: '#/components/schemas/OutputFormatText'
        - $ref: '#/components/schemas/OutputFormatJsonSchema'
    SnapshotFileDiff:
      type: object
      properties:
        file:
          type: string
        patch:
          type: string
        additions:
          type: number
        deletions:
          type: number
        status:
          type: string
          enum:
            - added
            - deleted
            - modified
      required:
        - file
        - patch
        - additions
        - deletions
    ProviderAuthError:
      type: object
      properties:
        name:
          type: string
          const: ProviderAuthError
        data:
          type: object
          properties:
            providerID:
              type: string
            message:
              type: string
          required:
            - providerID
            - message
      required:
        - name
        - data
    UnknownError:
      type: object
      properties:
        name:
          type: string
          const: UnknownError
        data:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - name
        - data
    MessageOutputLengthError:
      type: object
      properties:
        name:
          type: string
          const: MessageOutputLengthError
        data:
          type: object
          properties: {}
      required:
        - name
        - data
    MessageAbortedError:
      type: object
      properties:
        name:
          type: string
          const: MessageAbortedError
        data:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - name
        - data
    StructuredOutputError:
      type: object
      properties:
        name:
          type: string
          const: StructuredOutputError
        data:
          type: object
          properties:
            message:
              type: string
            retries:
              type: number
          required:
            - message
            - retries
      required:
        - name
        - data
    ContextOverflowError:
      type: object
      properties:
        name:
          type: string
          const: ContextOverflowError
        data:
          type: object
          properties:
            message:
              type: string
            responseBody:
              type: string
          required:
            - message
      required:
        - name
        - data
    APIError:
      type: object
      properties:
        name:
          type: string
          const: APIError
        data:
          type: object
          properties:
            message:
              type: string
            statusCode:
              type: number
            isRetryable:
              type: boolean
            responseHeaders:
              type: object
              propertyNames:
                type: string
              additionalProperties:
                type: string
            responseBody:
              type: string
            metadata:
              type: object
              propertyNames:
                type: string
              additionalProperties:
                type: string
          required:
            - message
            - isRetryable
      required:
        - name
        - data
    FilePartSource:
      anyOf:
        - $ref: '#/components/schemas/FileSource'
        - $ref: '#/components/schemas/SymbolSource'
        - $ref: '#/components/schemas/ResourceSource'
    ToolState:
      anyOf:
        - $ref: '#/components/schemas/ToolStatePending'
        - $ref: '#/components/schemas/ToolStateRunning'
        - $ref: '#/components/schemas/ToolStateCompleted'
        - $ref: '#/components/schemas/ToolStateError'
    OutputFormatText:
      type: object
      properties:
        type:
          type: string
          const: text
      required:
        - type
    OutputFormatJsonSchema:
      type: object
      properties:
        type:
          type: string
          const: json_schema
        schema:
          $ref: '#/components/schemas/JSONSchema'
        retryCount:
          default: 2
          type: integer
          minimum: 0
          maximum: 9007199254740991
      required:
        - type
        - schema
    FileSource:
      type: object
      properties:
        text:
          $ref: '#/components/schemas/FilePartSourceText'
        type:
          type: string
          const: file
        path:
          type: string
      required:
        - text
        - type
        - path
    SymbolSource:
      type: object
      properties:
        text:
          $ref: '#/components/schemas/FilePartSourceText'
        type:
          type: string
          const: symbol
        path:
          type: string
        range:
          $ref: '#/components/schemas/Range'
        name:
          type: string
        kind:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - text
        - type
        - path
        - range
        - name
        - kind
    ResourceSource:
      type: object
      properties:
        text:
          $ref: '#/components/schemas/FilePartSourceText'
        type:
          type: string
          const: resource
        clientName:
          type: string
        uri:
          type: string
      required:
        - text
        - type
        - clientName
        - uri
    ToolStatePending:
      type: object
      properties:
        status:
          type: string
          const: pending
        input:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        raw:
          type: string
      required:
        - status
        - input
        - raw
    ToolStateRunning:
      type: object
      properties:
        status:
          type: string
          const: running
        input:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        title:
          type: string
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        time:
          type: object
          properties:
            start:
              type: number
          required:
            - start
      required:
        - status
        - input
        - time
    ToolStateCompleted:
      type: object
      properties:
        status:
          type: string
          const: completed
        input:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        output:
          type: string
        title:
          type: string
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        time:
          type: object
          properties:
            start:
              type: number
            end:
              type: number
            compacted:
              type: number
          required:
            - start
            - end
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/FilePart'
      required:
        - status
        - input
        - output
        - title
        - metadata
        - time
    ToolStateError:
      type: object
      properties:
        status:
          type: string
          const: error
        input:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        error:
          type: string
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        time:
          type: object
          properties:
            start:
              type: number
            end:
              type: number
          required:
            - start
            - end
      required:
        - status
        - input
        - error
        - time
    JSONSchema:
      type: object
      propertyNames:
        type: string
      additionalProperties: {}
    FilePartSourceText:
      type: object
      properties:
        value:
          type: string
        start:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        end:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - value
        - start
        - end
    Range:
      type: object
      properties:
        start:
          type: object
          properties:
            line:
              type: number
            character:
              type: number
          required:
            - line
            - character
        end:
          type: object
          properties:
            line:
              type: number
            character:
              type: number
          required:
            - line
            - character
      required:
        - start
        - end

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.