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

# Create Thread

> Create a thread.



## OpenAPI

````yaml /langsmith/agent-server-openapi.json post /threads
openapi: 3.1.0
info:
  title: LangSmith Deployment
  version: 0.1.0
servers: []
security: []
tags:
  - name: Assistants
    description: An assistant is a configured instance of a graph.
  - name: Threads
    description: A thread contains the accumulated outputs of a group of runs.
  - name: Thread Runs
    description: >-
      A run is an invocation of a graph / assistant on a thread. It updates the
      state of the thread.
  - name: Stateless Runs
    description: >-
      A run is an invocation of a graph / assistant, with no state or memory
      persistence.
  - name: Crons
    description: >-
      A cron is a periodic run that recurs on a given schedule. The repeats can
      be isolated, or share state in a thread
  - name: Store
    description: >-
      Store is an API for managing persistent key-value store (long-term memory)
      that is available from any thread.
  - name: A2A
    description: >-
      Agent-to-Agent Protocol related endpoints for exposing assistants as
      A2A-compliant agents.
  - name: MCP
    description: >-
      Model Context Protocol related endpoints for exposing an agent as an MCP
      server.
  - name: System
    description: System endpoints for health checks, metrics, and server information.
paths:
  /threads:
    post:
      tags:
        - Threads
      summary: Create Thread
      description: Create a thread.
      operationId: create_thread_threads_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ThreadCreate'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thread'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ThreadCreate:
      properties:
        thread_id:
          type: string
          format: uuid
          title: Thread Id
          description: >-
            The ID of the thread. If not provided, a random UUID will be
            generated.
        metadata:
          type: object
          title: Metadata
          description: Metadata to add to thread.
        if_exists:
          type: string
          enum:
            - raise
            - do_nothing
          title: If Exists
          description: >-
            How to handle duplicate creation. Must be either 'raise' (raise
            error if duplicate), or 'do_nothing' (return existing thread).
          default: raise
        ttl:
          type: object
          title: TTL
          description: The time-to-live for the thread.
          properties:
            strategy:
              type: string
              enum:
                - delete
                - keep_latest
              description: >-
                The TTL strategy. 'delete' removes the entire thread.
                'keep_latest' prunes old checkpoints but keeps the thread and
                its latest state.
              default: delete
            ttl:
              type: number
              description: >-
                The time-to-live in minutes from now until thread should be
                swept.
        supersteps:
          type: array
          items:
            type: object
            properties:
              updates:
                type: array
                items:
                  $ref: '#/components/schemas/ThreadSuperstepUpdate'
            required:
              - updates
      type: object
      title: ThreadCreate
      description: Payload for creating a thread.
    Thread:
      properties:
        thread_id:
          type: string
          format: uuid
          title: Thread Id
          description: The ID of the thread.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: The time the thread was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: The last time the thread was updated.
        state_updated_at:
          type: string
          format: date-time
          title: State Updated At
          description: The last time the thread state was updated.
        metadata:
          type: object
          title: Metadata
          description: The thread metadata.
        config:
          type: object
          title: Config
          description: The thread config.
        status:
          type: string
          enum:
            - idle
            - busy
            - interrupted
            - error
          title: Status
          description: The status of the thread.
        values:
          type: object
          title: Values
          description: The current state of the thread.
        interrupts:
          type: object
          title: Interrupts
          description: The current interrupts of the thread.
        ttl:
          type: object
          title: TTL Info
          description: >-
            TTL information if set for this thread. Only present when
            ?include=ttl is passed.
          properties:
            strategy:
              type: string
              enum:
                - delete
                - keep_latest
              description: The TTL strategy.
            ttl_minutes:
              type: number
              description: The TTL in minutes.
            expires_at:
              type: string
              format: date-time
              description: When the thread will expire.
        extracted:
          type: object
          title: Extracted
          description: >-
            Extracted values from thread JSONB columns, populated when extract
            is specified in search request.
      type: object
      required:
        - thread_id
        - created_at
        - updated_at
        - metadata
        - status
      title: Thread
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: Human-readable error message
      title: ErrorResponse
      description: Error response returned from the server
    ThreadSuperstepUpdate:
      properties:
        values:
          anyOf:
            - items:
                type: object
              type: array
            - type: object
            - type: 'null'
        command:
          anyOf:
            - $ref: '#/components/schemas/Command'
            - type: 'null'
          description: The command associated with the update.
        as_node:
          type: string
          description: Update the state as if this node had just executed.
      required:
        - as_node
      type: object
    Command:
      type: object
      title: Command
      description: The command to run.
      properties:
        update:
          type:
            - object
            - array
            - 'null'
          title: Update
          description: An update to the state.
        resume:
          type:
            - object
            - array
            - number
            - string
            - boolean
            - 'null'
          title: Resume
          description: A value to pass to an interrupted node.
        goto:
          anyOf:
            - $ref: '#/components/schemas/Send'
            - type: array
              items:
                $ref: '#/components/schemas/Send'
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Goto
          description: >-
            Name of the node(s) to navigate to next or node(s) to be executed
            with a provided input.
    Send:
      type: object
      title: Send
      description: A message to send to a node.
      properties:
        node:
          type: string
          title: Node
          description: The node to send the message to.
        input:
          type:
            - object
            - array
            - number
            - string
            - boolean
            - 'null'
          title: Message
          description: The message to send.
      required:
        - node
        - input

````