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

# Get an agent thread's run tree

> <p> Get the runs of a thread as a tree (via parent_run_id). Use it to detect branches (sibling runs from edit/regenerate) and pick a run to restore (restore via the run events endpoints). </p> <p> Required scope: `inference:run` </p>




## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/qaip/openapi.documented.yml get /agent/threads/{thread_id}
openapi: 3.0.3
info:
  title: QAIP APIs
  version: 1.0.0
servers:
  - url: https://developer.qaip.com/api/v1
    description: API base path
security:
  - ApiKeyAuth: []
tags:
  - name: completions
    description: Generate completions
  - name: search
    description: Search content
  - name: query
    description: Query materialized external tables
  - name: extract
    description: Data extraction using LLM
  - name: tags
    description: List available tags
  - name: agent
    description: (Experimental) Agent operations
  - name: tag-source-groups
    description: Tag and source group associations
  - name: source-groups
    description: Source group (job) management and metadata
  - name: sources
    description: Sources management and metadata
  - name: local-file-groups
    description: Local file group management
  - name: secrets
    description: Secret management
  - name: google-drives
    description: Google Drive data source management
  - name: google-drive-settings
    description: Google Drive data source setting management
  - name: crawls
    description: Web crawl data source management
  - name: crawl-settings
    description: Web crawl setting management
  - name: githubs
    description: GitHub data source management
  - name: github-settings
    description: GitHub data source setting management
  - name: notions
    description: Notion data source management
  - name: notion-settings
    description: Notion data source setting management
  - name: authz-subject-attributes
    description: >-
      Authorization subject attribute management (requires the `authz:grant`
      scope)
  - name: redaction-policies
    description: >-
      Tenant redaction policy management (requires the `policy:redaction:manage`
      scope)
  - name: api-keys
    description: API key issuance (requires the `apikeys:issue` scope)
paths:
  /agent/threads/{thread_id}:
    get:
      tags:
        - agent
      summary: Get an agent thread's run tree
      description: >
        <p> Get the runs of a thread as a tree (via parent_run_id). Use it to
        detect branches (sibling runs from edit/regenerate) and pick a run to
        restore (restore via the run events endpoints). </p> <p> Required scope:
        `inference:run` </p>
      operationId: getAgentThread
      parameters:
        - name: thread_id
          in: path
          required: true
          schema:
            type: string
        - name: principal_id
          in: query
          required: false
          description: >
            Scope by principal. If omitted, only a thread with no principal
            (principal_id is null) is returned; a thread whose principal differs
            yields 404.
          schema:
            type: string
      responses:
        '200':
          description: Agent thread run tree
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentThreadDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AgentThreadDetail:
      type: object
      required:
        - thread_id
        - runs
      properties:
        thread_id:
          type: string
        runs:
          type: array
          description: All runs in the thread as a tree (via parent_run_id).
          items:
            $ref: '#/components/schemas/AgentRunNode'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              description: Human-readable error message
            type:
              type: string
              description: Machine-readable error code
    AgentRunNode:
      type: object
      required:
        - run_id
        - status
      properties:
        run_id:
          type: string
        parent_run_id:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/AgentRunStatus'
        title:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time
    AgentRunStatus:
      type: string
      description: Agent run lifecycle state.
      enum:
        - QUEUED
        - RUNNING
        - CANCELLING
        - SUCCEEDED
        - FAILED
        - CANCELLED
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````