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

# List Thread Messages

> Retrieves a list of messages for a specific thread.

This endpoint allows you to retrieve a list of messages for a specific thread. Messages are an essential part of the thread, representing the conversation history between the user and the AI assistant.

## Pagination

This endpoint supports pagination in the same way as the Threads API. It uses the `limit` parameter to specify the maximum number of messages per request, and the `after` parameter as a cursor for pagination. The response includes a `has_more` parameter to indicate if more results are available.

For detailed information on how pagination works, refer to the Threads API documentation.


## OpenAPI

````yaml GET /v2/threads/{threadId}/messages
openapi: 3.0.0
info:
  version: 1.0.0
  title: Langtail prompt endpoint
servers: []
security: []
paths:
  /v2/threads/{threadId}/messages:
    get:
      description: Retrieves a list of messages for a specific thread.
      parameters:
        - schema:
            type: string
            example: <LANGTAIL_API_KEY>
          required: true
          description: Your Langtail API Key
          name: X-API-Key
          in: header
        - name: threadId
          in: path
          required: true
          description: The ID of the thread to retrieve messages from.
          schema:
            type: string
        - schema:
            type: number
            nullable: true
          name: limit
          in: query
          description: The maximum number of threads to return. Default is 100.
        - schema:
            type: string
            nullable: true
          name: after
          in: query
          description: >-
            A cursor for use in pagination. 'after' is a thread ID that defines
            your place in the list. For instance, if you make a list request and
            receive 100 threads, ending with thread 'xyz', your subsequent call
            can include after='xyz' in order to fetch the next page of the list.
            Pagination works the same as in the OpenAI API
            https://platform.openai.com/docs/api-reference/assistants/listAssistants.
        - schema:
            type: string
            nullable: true
            default: asc
            enum:
              - asc
              - desc
          name: order
          in: query
          description: >-
            The order of the messages. Default is 'asc' (oldest first). Use
            'desc' for newest first.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    enum:
                      - list
                    description: >-
                      The object type, which is always 'list' for a list of
                      messages.
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: The unique identifier for the message.
                        createdAt:
                          type: string
                          format: date-time
                          description: The timestamp when the message was created.
                        threadId:
                          type: string
                          description: The ID of the thread this message belongs to.
                        content:
                          type: array
                          items:
                            type: object
                            properties:
                              role:
                                type: string
                                enum:
                                  - assistant
                                  - user
                                  - system
                                  - function
                                  - tool
                              content:
                                anyOf:
                                  - type: string
                                    description: Text content
                                    nullable: false
                                  - type: array
                                    description: Mix of text and images.
                                    items:
                                      anyOf:
                                        - type: object
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - text
                                            text:
                                              type: string
                                          required:
                                            - type
                                            - text
                                        - type: object
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - image_url
                                            image_url:
                                              type: object
                                              properties:
                                                url:
                                                  type: string
                                                detail:
                                                  type: string
                                                  enum:
                                                    - auto
                                                    - low
                                                    - high
                                                  default: auto
                                              required:
                                                - url
                                                - detail
                                          required:
                                            - type
                                            - image_url
                                  - nullable: true
                                    description: >-
                                      Can be omited if there is a
                                      `function_call` or `tool_calls`
                              function_call:
                                type: object
                                properties:
                                  name:
                                    type: string
                                  arguments:
                                    type: string
                                required:
                                  - name
                                  - arguments
                              tool_calls:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: string
                                    type:
                                      type: string
                                      enum:
                                        - function
                                    function:
                                      type: object
                                      properties:
                                        name:
                                          type: string
                                        arguments:
                                          type: string
                                      required:
                                        - name
                                        - arguments
                                  required:
                                    - id
                                    - type
                                    - function
                              tool_choice:
                                anyOf:
                                  - type: string
                                    enum:
                                      - auto
                                  - type: string
                                    enum:
                                      - none
                                  - type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - function
                                      function:
                                        type: object
                                        properties:
                                          name:
                                            type: string
                                        required:
                                          - name
                                    required:
                                      - type
                                      - function
                              tool_call_id:
                                type: string
                            required:
                              - role
                              - content
                          description: >-
                            Additional messages. These will be appended to the
                            Prompt Template.
                          example:
                            - role: user
                              content: Hello
                        requestLogId:
                          type: string
                          nullable: true
                          description: The ID of the associated request log, if available.
                        metadata:
                          type: object
                          nullable: true
                          description: >-
                            A set of key-value pairs that can be attached to the
                            message.
                      required:
                        - id
                        - createdAt
                        - threadId
                  first_id:
                    type: string
                    description: >-
                      The ID of the first thread in the list, or null if the
                      list is empty.
                    nullable: true
                  last_id:
                    type: string
                    description: >-
                      The ID of the last thread in the list, or null if the list
                      is empty.
                    nullable: true
                  has_more:
                    type: boolean
                    description: Whether there are more threads available after this batch.
                required:
                  - data
                  - has_more
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        example: Invalid request parameters
                required:
                  - error
        '404':
          description: Thread not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        example: Thread not found
                required:
                  - error
      servers:
        - url: https://api.langtail.com

````