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

# Create Thread

> Create a new conversation thread.

Threads hold conversation state and checkpoint history. Provide a
`thread_id` for idempotent creation, or let the server generate one.
Set `if_exists` to `"do_nothing"` to return the existing thread when the
ID already exists instead of raising a 409 conflict.



## OpenAPI

````yaml /openapi.json post /threads
openapi: 3.1.0
info:
  title: Aegra
  description: Production-ready Agent Protocol server
  version: 0.9.24
servers: []
security: []
tags:
  - name: Assistants
    description: A configured instance of a graph.
  - name: Threads
    description: Accumulated state and outputs from a group of runs.
  - name: Thread Runs
    description: Invoke a graph on a thread, updating its persistent state.
  - name: Stateless Runs
    description: Invoke a graph without state or memory persistence.
  - name: Crons
    description: Scheduled recurring runs on a cron schedule.
  - name: Store
    description: Persistent key-value and semantic storage available from any thread.
  - name: Event Streaming
    description: Agent Protocol v2 thread event streaming and commands.
  - name: Health
    description: Server health checks and service information.
paths:
  /threads:
    post:
      tags:
        - Threads
      summary: Create Thread
      description: |-
        Create a new conversation thread.

        Threads hold conversation state and checkpoint history. Provide a
        `thread_id` for idempotent creation, or let the server generate one.
        Set `if_exists` to `"do_nothing"` to return the existing thread when the
        ID already exists instead of raising a 409 conflict.
      operationId: create_thread_threads_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ThreadCreate'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thread'
        '409':
          description: Resource state conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentProtocolError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ThreadCreate:
      properties:
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Thread metadata
        initial_state:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Initial State
          description: LangGraph initial state
        threadId:
          anyOf:
            - type: string
            - type: 'null'
          title: Threadid
          description: Optional client-provided thread ID for idempotent creation
        ifExists:
          anyOf:
            - type: string
            - type: 'null'
          title: Ifexists
          description: 'Behavior when thread exists: ''raise'' (default) or ''do_nothing'''
          default: raise
      type: object
      title: ThreadCreate
      description: Request model for creating threads
    Thread:
      properties:
        thread_id:
          type: string
          title: Thread Id
          description: Unique identifier for the thread.
        status:
          type: string
          title: Status
          description: 'Current thread status: idle, busy, interrupted, or error.'
          default: idle
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
          description: Arbitrary metadata attached to the thread.
        user_id:
          type: string
          title: User Id
          description: Identifier of the user who owns this thread.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when the thread was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Timestamp when the thread was last updated.
      type: object
      required:
        - thread_id
        - user_id
        - created_at
        - updated_at
      title: Thread
      description: |-
        Thread entity model

        Status values: idle, busy, interrupted, error
    AgentProtocolError:
      properties:
        error:
          type: string
          title: Error
          description: Error type
        message:
          type: string
          title: Message
          description: Human-readable error message
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: Additional error details
      type: object
      required:
        - error
        - message
      title: AgentProtocolError
      description: Standard Agent Protocol error response
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````