Skip to main content
GET
/
v1
/
tasks
/
{task_id}
/
thread
Get Task'S Thread
curl --request GET \
  --url https://api.xpander.ai/v1/tasks/{task_id}/thread \
  --header 'x-api-key: <api-key>'
[
  {
    "role": "user",
    "content": "How do I reset my password?"
  },
  {
    "role": "assistant",
    "content": "To reset your password, visit the login page and click 'Forgot Password'. You'll receive a reset link via email."
  }
]
Retrieve the root conversation thread for a task/thread ID as a simple array. When you continue a conversation by passing the same invocation id, the new turns are appended here under that same task/thread ID.

Path Parameters

task_id
string
required
Unique identifier of the task (UUID format)

Response

Returns an array of message objects representing the root conversation:
[array]
array
Array of conversation messages

Example Request

curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread"

Example Response

Multi-turn conversation thread:
[
  {
    "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

Pretty print the conversation:
curl -s -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread" | \
  jq '.[] | "\(.role): \(.content)"'
Count messages in the thread:
curl -s -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread" | \
  jq 'length'
Extract the latest assistant response:
curl -s -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/thread" | \
  jq '[.[] | select(.role == "assistant")][-1].content'

Use Cases

  • View conversation history - See the complete interaction between user and agent
  • Review agent responses - Understand what the agent said and its reasoning
  • Track token usage - Monitor LLM API costs per message
  • Audit conversations - Review interaction history for compliance

Notes

  • Returns only the root task’s messages (excludes sub-task buckets)
  • Continuing a conversation with the same invocation id appends new turns to this array
  • For multi-agent workflows with sub-tasks, use Get Task Thread (Full)
  • Messages are ordered chronologically by creation time

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

task_id
string
required

Response

Successful Response