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

# Search Threads

> Search threads with filters.

Filter by status or metadata key-value pairs. Results are paginated via
`limit` and `offset` and ordered by creation time (newest first).



## OpenAPI

````yaml /openapi.json post /threads/search
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/search:
    post:
      tags:
        - Threads
      summary: Search Threads
      description: |-
        Search threads with filters.

        Filter by status or metadata key-value pairs. Results are paginated via
        `limit` and `offset` and ordered by creation time (newest first).
      operationId: search_threads_threads_search_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ThreadSearchRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/Thread'
                type: array
                title: Response Search Threads Threads Search Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ThreadSearchRequest:
      properties:
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Metadata filters
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
          description: Thread status filter (idle, busy, interrupted, error)
        limit:
          anyOf:
            - type: integer
              maximum: 100
              minimum: 1
            - type: 'null'
          title: Limit
          description: Maximum results
          default: 20
        offset:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Offset
          description: Results offset
          default: 0
        order_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Order By
          description: >-
            DEPRECATED: use sort_by + sort_order. Legacy single-field form, e.g.
            'updated_at ASC'.
          default: created_at DESC
          deprecated: true
        sort_by:
          anyOf:
            - type: string
              enum:
                - thread_id
                - status
                - created_at
                - updated_at
            - type: 'null'
          title: Sort By
          description: Field to sort by (SDK-compatible). Takes precedence over order_by.
        sort_order:
          anyOf:
            - type: string
              enum:
                - asc
                - desc
            - type: 'null'
          title: Sort Order
          description: >-
            Sort direction (SDK-compatible). Defaults to 'desc' when sort_by is
            set.
      type: object
      title: ThreadSearchRequest
      description: Request model for thread search
    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
    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

````