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

# Update a Thread by ID

> Updates a thread's metadata by its ID.

This endpoint allows you to update the metadata of a thread by its unique identifier. Metadata is a key-value storage system that developers can use to store useful information associated with a thread.

## Metadata Usage

Metadata can be used to store various types of information related to the thread, such as:

* User information (e.g., user ID, name, preferences)
* Conversation context (e.g., topic, category, priority)
* Custom flags or tags
* Timestamps for specific events
* Any other relevant data for your application


## OpenAPI

````yaml POST /v2/threads/{threadId}
openapi: 3.0.0
info:
  version: 1.0.0
  title: Langtail prompt endpoint
servers: []
security: []
paths:
  /v2/threads/{threadId}:
    post:
      description: Updates a thread's metadata by its ID.
      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 update.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                metadata:
                  type: object
                  description: >-
                    A set of key-value pairs that can be attached to the thread.
                    This can be used to store additional information about the
                    thread to facilitate filtering or organization. Note that
                    the new metadata provided will completely overwrite any
                    existing metadata for the thread.
                  example:
                    user_id: user_123
                    conversation_topic: product_inquiry
                    priority: high
              required:
                - metadata
      responses:
        '200':
          description: Successfully updated thread
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: The unique identifier for the thread.
                  createdAt:
                    type: integer
                    description: >-
                      The Unix timestamp (in seconds) of when the thread was
                      created.
                  projectId:
                    type: string
                    description: The ID of the project this thread belongs to.
                  createLog:
                    type: object
                    description: >-
                      A log created by the first message that creates the
                      thread.
                    nullable: true
                    properties:
                      id:
                        type: string
                        description: The unique identifier for the log.
                      url:
                        type: string
                        description: The URL of the request.
                      stream:
                        type: boolean
                        description: Indicates if the request was streamed.
                      metadata:
                        type: string
                        description: Additional metadata associated with the log.
                      promptId:
                        type: string
                        description: The ID of the prompt used.
                      threadId:
                        type: string
                        nullable: true
                        description: The ID of the associated thread, if any.
                      assistant:
                        type: boolean
                        description: Indicates if an assistant was used.
                      projectId:
                        type: string
                        description: The ID of the project.
                      requestIP:
                        type: string
                        description: The IP address of the request.
                      startedAt:
                        type: string
                        format: date-time
                        description: The timestamp when the request started.
                      variables:
                        type: string
                        description: Variables used in the request.
                      parameters:
                        type: string
                        description: Parameters used in the request.
                      promptSlug:
                        type: string
                        description: The slug of the prompt used.
                      doNotRecord:
                        type: boolean
                        description: Indicates if the request should not be recorded.
                      environment:
                        type: string
                        description: The environment in which the request was made.
                      openAIKeyId:
                        type: string
                        description: The ID of the OpenAI key used.
                      projectSlug:
                        type: string
                        description: The slug of the project.
                      requestData:
                        type: string
                        description: Data associated with the request.
                      deploymentId:
                        type: string
                        description: The ID of the deployment.
                      organizationId:
                        type: string
                        description: The ID of the organization.
                      projectAPIKeyId:
                        type: string
                        description: The ID of the project API key.
                      organizationSlug:
                        type: string
                        description: The slug of the organization.
                      deploymentVersion:
                        type: string
                        nullable: true
                        description: The version of the deployment, if applicable.
                      promptHistoryHash:
                        type: string
                        description: A hash of the prompt history.
                      openAIOrganization:
                        type: string
                        nullable: true
                        description: The OpenAI organization, if applicable.
                  metadata:
                    type: object
                    description: The updated set of key-value pairs attached to the thread.
                    example:
                      user_id: user_123
                      conversation_topic: product_inquiry
                      priority: high
                required:
                  - id
                  - createdAt
                  - projectId
                  - metadata
        '400':
          description: Metadata is required
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        example: Metadata is required
                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

````