Skip to main content
GET
/
v1
/
tasks
/
{task_id}
Get Task
curl --request GET \
  --url https://api.xpander.ai/v1/tasks/{task_id} \
  --header 'x-api-key: <api-key>'
{
  "id": "04dbe342-27ef-4fcb-bc16-f19457e892b3",
  "agent_id": "93a1cd50-2af0-452a-99a0-6e1f1b14fb29",
  "status": "completed",
  "input": {
    "text": "How do I reset my password?",
    "files": []
  },
  "result": "To reset your password, visit the login page and click 'Forgot Password'. You'll receive a reset link via email within a few minutes.",
  "created_at": "2026-02-07T06:18:47.438043Z",
  "started_at": "2026-02-07T06:18:48.201887Z",
  "finished_at": "2026-02-07T06:18:55.784755Z",
  "organization_id": "91fbe9bc-35b3-41e8-b59d-922fb5a0f031"
}
Get complete details about a task/thread record including its current status, latest input, latest result, and execution timing. This endpoint is essential for polling async tasks and for inspecting the latest turn of a continued conversation.

Path Parameters

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

Response

id
string
Task/thread identifier. Reuse this as id in later invokes to continue the same conversation.
agent_id
string
UUID of the agent that executed this task
organization_id
string
UUID of the organization that owns this task
input
object
Latest input stored on this task/thread record
status
string
Current task status: pending, executing, paused, error, failed, completed, or stopped
result
string
Latest task result. This is usually plain text or markdown. Only parse it as JSON if you explicitly requested JSON/structured output.
output_format
string
Output format for the latest result, such as markdown or json
created_at
string
ISO 8601 timestamp of when the task was created
started_at
string
ISO 8601 timestamp of when execution began (null if not started)
finished_at
string
ISO 8601 timestamp of when the task finished (null if still running)
source
string
Source of the task creation: api, sdk, dashboard, webhook
events_streaming
boolean
Whether the task used event streaming
sub_executions
array
Array of sub-task UUIDs spawned by this task
parent_execution
string
UUID of parent task if this is a sub-task (null otherwise)
payload_extension
object
Additional metadata (nullable)
In a multi-turn conversation, this endpoint shows the latest input and latest result for the reused task/thread ID. Use Get Task Thread or Get Task Thread (Full) for the full message history.

Example Request

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

Example Response

{
  "id": "fbd08e4d-cfa7-4838-b6e6-e51855ac2ba3",
  "agent_id": "<agent-id>",
  "organization_id": "<org-id>",
  "input": {
    "text": "Reply with exactly SECOND",
    "files": [],
    "user": null
  },
  "status": "completed",
  "created_at": "2026-03-23T00:45:26.965823Z",
  "started_at": null,
  "finished_at": "2026-03-23T00:45:30.532954Z",
  "result": "SECOND",
  "source": "api",
  "output_format": "markdown",
  "events_streaming": true,
  "sub_executions": [],
  "parent_execution": null,
  "payload_extension": null
}

Extracting Results

For normal text or markdown responses:
curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>" | jq -r '.result'
Only use fromjson when you explicitly requested JSON output:
curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>" | jq '.result | fromjson'

Status Polling Pattern

For async workflows, poll until status is no longer pending or executing:
# Poll every 2 seconds until task completes
while true; do
  TASK=$(curl -s -H "x-api-key: <your-api-key>" \
    "https://api.xpander.ai/v1/tasks/<task-id>")

  STATUS=$(echo $TASK | jq -r '.status')

  if [[ $STATUS == "completed" ]]; then
    echo $TASK | jq -r '.result'
    break
  fi

  sleep 2
done

Use Cases

  • Retrieve task results - Get final output after async execution
  • Check execution status - Monitor if task is still executing
  • Track timing - See created_at, started_at, finished_at for performance analysis
  • Get latest-turn details - Review the most recent input and output for a continued conversation

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

task_id
string
required

Response

Successful Response

id
string

Task/thread ID. Pass this back as id in your next request to continue the conversation.

agent_id
string

Unique identifier of the agent that executed this task

input
AgentExecutionInput · object

The input that was provided to the agent

status
enum<string> | null

Task execution status: pending, executing, paused, completed, failed, error, or stopped

Available options:
pending,
executing,
paused,
error,
failed,
completed,
stopped
created_at
string<date-time>

ISO 8601 timestamp when the task was created

started_at
string<date-time> | null

ISO 8601 timestamp when the task started executing

paused_at
string<date-time> | null

ISO 8601 timestamp when the task was paused (for HITL scenarios)

finished_at
string<date-time> | null

ISO 8601 timestamp when the task completed

result
string | null

The agent's response. If output_format is json, this is a JSON string - parse it with JSON.parse() or jq

organization_id
string

Organization UUID