> ## 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.

# Create Thread Message

> Create a new message in a thread.

Use this endpoint to add a message to a thread without calling the LLM.

In most cases, you should use the [Invoke Assistant API](api-reference/endpoint/invoke-assistant) to add messages and get a response from the LLM.
However, this endpoint is useful when you need to add messages without immediate LLM processing, such as for creating placeholder messages or updating thread content separately.


## OpenAPI

````yaml POST /v2/threads/{threadId}/messages
openapi: 3.0.0
info:
  version: 1.0.0
  title: Langtail prompt endpoint
servers: []
security: []
paths:
  /v2/threads/{threadId}/messages:
    post:
      description: Create a new message in a 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.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                message:
                  type: object
                  description: Message that will be added to the thread.
                  properties:
                    role:
                      type: string
                      enum:
                        - assistant
                        - user
                        - system
                        - function
                        - tool
                    name:
                      type: string
                    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
                metadata:
                  type: object
                  description: >-
                    A set of key-value pairs that can be attached to the
                    message.
                  example:
                    user_id: user_123
                    conversation_topic: product_inquiry
                    priority: high
              required:
                - message
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                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
                  metadata:
                    type: object
                    description: >-
                      A key-value store for additional metadata associated with
                      the message.
                    additionalProperties:
                      type: string
                    nullable: true
                  requestLog:
                    type: object
                    description: Information about the request log, if available.
                    properties:
                      id:
                        type: string
                        description: The unique identifier for the request log.
                      createdAt:
                        type: string
                        format: date-time
                        description: The timestamp when the request log was created.
                      request:
                        type: object
                        description: Details of the request made.
                      response:
                        type: object
                        description: Details of the response received.
                    nullable: true
                  requestLogId:
                    type: string
                    description: The unique identifier for the request log, if available.
                    nullable: true
                required:
                  - id
                  - createdAt
                  - threadId
        '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

````