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

# Get Task Thread (Full)

> Get complete conversation thread including all sub-task messages and tool calls

Retrieve the complete conversation thread for a task/thread ID, including the root conversation and any sub-task message buckets. This is the authoritative message-history endpoint for multi-turn conversations continued with the same invocation `id`.

## Path Parameters

<ParamField path="task_id" type="string" required>
  Unique identifier of the task (UUID format)
</ParamField>

## Response

Returns an object where `root` contains the main conversation and additional keys may appear for sub-task IDs:

<ResponseField name="root" type="array">
  Array of messages from the root task

  <Expandable title="Message Object">
    <ResponseField name="id" type="string">
      Unique message identifier (UUID)
    </ResponseField>

    <ResponseField name="role" type="string">
      Message role: `user`, `assistant`, `system`, or `tool`
    </ResponseField>

    <ResponseField name="content" type="string">
      Message content text
    </ResponseField>

    <ResponseField name="created_at" type="integer">
      Unix timestamp of message creation
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="[sub_task_id]" type="array">
  For each sub-task, an array of messages with the same structure as `root`. The key is the UUID of the sub-task.
</ResponseField>

## Example Request

```bash theme={"dark"}
curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread/full"
```

## Example Response

```json theme={"dark"}
{
  "root": [
    {
      "id": "<task-id>_user_1",
      "role": "user",
      "content": "Reply with exactly FIRST",
      "created_at": 1774226722
    },
    {
      "id": "<task-id>_agent_1",
      "role": "assistant",
      "content": "FIRST",
      "created_at": 1774226726
    },
    {
      "id": "<task-id>_user_2",
      "role": "user",
      "content": "Reply with exactly SECOND",
      "created_at": 1774226726
    },
    {
      "id": "<task-id>_agent_2",
      "role": "assistant",
      "content": "SECOND",
      "created_at": 1774226730
    }
  ]
}
```

## Parsing Examples

**Get all task IDs (root + sub-tasks):**

```bash theme={"dark"}
curl -s -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread/full" | \
  jq 'keys'
```

**Count messages in each task:**

```bash theme={"dark"}
curl -s -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread/full" | \
  jq 'map_values(length)'
```

**Print the root conversation:**

```bash theme={"dark"}
curl -s -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread/full" | \
  jq '.root[] | "\(.role): \(.content)"'
```

**Flatten all messages across root and sub-tasks:**

```bash theme={"dark"}
curl -s -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread/full" | \
  jq 'to_entries | map(.value[]) | .[] | "\(.role): \(.content)"'
```

## Use Cases

* **Debug multi-agent workflows** - See the complete execution tree with all sub-agents
* **Analyze token usage** - Track token consumption across all sub-tasks and calculate costs
* **Audit conversations** - Review complete interaction history including internal routing
* **Performance analysis** - Measure response times and token efficiency per sub-task
* **Troubleshoot failures** - See all tool calls and system messages that led to errors

## Comparison with /thread Endpoint

| Feature                      | /thread | /thread/full                            |
| ---------------------------- | ------- | --------------------------------------- |
| Root task messages           | ✅       | ✅                                       |
| Multi-turn root conversation | ✅       | ✅                                       |
| Sub-task message buckets     | ❌       | ✅                                       |
| Response structure           | Array   | Object keyed by `root` and sub-task IDs |

## Notes

* The `root` key contains the main conversation for the task/thread ID you requested
* Continuing a conversation with the same invocation `id` appends new turns to `root`
* Multi-agent or delegated runs can add extra keys for sub-task IDs
* Messages are ordered chronologically within each task bucket

## See Also

* [Get Task Thread](/api-reference/v1/tasks/get-thread) - Get the root task thread only
* [Get Task](/api-reference/v1/tasks/get-task) - Get the latest task state and result
* [List Tasks](/api-reference/v1/tasks/list-tasks) - List all tasks


## OpenAPI

````yaml GET /v1/tasks/{task_id}/thread/full
openapi: 3.1.0
info:
  title: xpander.ai API Service
  description: |2-

        The xpander.ai API Service provides a unified REST API for managing AI agents,
        executing tasks, managing knowledge bases, and integrating with external systems.
        
        Features:
        - Agent Management: Create, update, deploy, and delete AI agents
        - Task Execution: Invoke agents with support for sync, async, and streaming modes
        - Knowledge Bases: Manage knowledge bases and documents for RAG workflows
        - Tools: Discover, connect, and attach tools (connectors, custom functions, MCP servers, sub-agents, workflows) to agents and workflows
        - MCP Integration: Model Context Protocol support for standardized AI interactions
        
        Authentication: All endpoints require authentication via either an API key (`x-api-key`) or an OAuth2 JWT (`Authorization: Bearer <jwt>`).
        
  version: '0.001'
servers:
  - url: https://api.xpander.ai
security: []
paths:
  /v1/tasks/{task_id}/thread/full:
    get:
      tags:
        - API v1
        - Tasks
        - Tasks CRUD
      summary: Get Task'S Full Thread
      description: Get Task's full thread including sub tasks
      operationId: Get_Task_s_full_thread_v1_tasks__task_id__thread_full_get
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
            title: Task Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    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
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      description: API Key for authentication
      in: header
      name: x-api-key

````