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

# Get Chat History

> This endpoint returns a list of messages and conversations between your customers and your trained agent



## OpenAPI

````yaml POST /get-chats/{bot_id}
openapi: 3.0.1
info:
  title: OpenAPI Plant Store
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.public.chatnode.ai/v1
security:
  - bearerAuth: []
paths:
  /get-chats/{bot_id}:
    post:
      description: >-
        This endpoint returns a list of messages and conversations between your
        customers and your trained agent
      parameters:
        - name: bot_id
          in: path
          description: The agent id associated with the trained agent model.
          required: true
          schema:
            type: string
        - name: k
          in: query
          description: >-
            Limit the number of conversations to look in the past
            "conversation_ids" will only find the conversations requested and
            ignore the "k" parameter
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              title: Conversation Session Ids
              type: array
              description: The conversation session ids associated with the trained agent.
              items:
                type: string
              example: []
      responses:
        '200':
          description: Chat History response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Chat'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Forbidden'
components:
  schemas:
    Chat:
      required:
        - id
        - message
        - session_id
        - created_at
      type: object
      properties:
        id:
          type: string
          description: The unique identifier for the chat.
          example: 9ds49k9cncp7bmp
        message:
          type: object
          properties:
            data:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - ai
                    - human
                  description: >-
                    The type of message data: 'ai' for artificial intelligence
                    messages, 'human' for user messages.
                content:
                  type: string
                  description: The content of the message.
                  example: Hello there! 😄 How can I assist you today?
            type:
              type: string
              enum:
                - ai
                - human
              description: >-
                The type of message: 'ai' for artificial intelligence messages,
                'human' for user messages.
          required:
            - type
          description: The message object containing data and type.
        session_id:
          type: string
          description: The session ID associated with the chat.
          example: aki56d7-1719768767426
        created_at:
          type: string
          format: date-time
          description: The date and time when the message was created.
          example: '2024-06-30T17:32:53.518+00:00'
    Unauthorized:
      required:
        - message
      type: object
      properties:
        message:
          type: string
          example: Bearer token missing or unknown
    Forbidden:
      required:
        - message
      type: object
      properties:
        message:
          type: string
          example: Bot access not allowed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````