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

# Get Chat History

> Retrieve the message history for a chat conversation.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/morphik/openapi.documented.yml get /chat/{chat_id}
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /chat/{chat_id}:
    get:
      summary: Get Chat History
      description: Retrieve the message history for a chat conversation.
      operationId: get_chat_history_chat__chat_id__get
      parameters:
        - name: chat_id
          in: path
          required: true
          schema:
            type: string
            title: Chat Id
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChatMessage'
                title: Response Get Chat History Chat  Chat Id  Get
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Morphik from 'morphik';

            const client = new Morphik({
              apiKey: process.env['MORPHIK_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.chat.retrieveHistory('chat_id');

            console.log(response);
        - lang: cURL
          source: |-
            curl https://api.morphik.ai/chat/$CHAT_ID \
                -H "Authorization: Bearer $MORPHIK_API_KEY"
components:
  schemas:
    ChatMessage:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          title: Role
        content:
          type: string
          title: Content
        timestamp:
          type: string
          title: Timestamp
      type: object
      required:
        - role
        - content
      title: ChatMessage
      description: Simple chat message model for chat persistence.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````