---
title: "Get Chat Task"
method: GET
path: "/v1/chat/tasks/{task_id}"
tags: ["sdk-v1"]
---

# Get Chat Task

`GET /v1/chat/tasks/{task_id}`

Return a snapshot of one task's current state.

SDK clients call this to poll a previously-submitted task for
its status, latest output, or failure reason. The shape is
deliberately flat -- detailed step-by-step execution data lives
behind ``GET /v1/chat/tasks/{task_id}/steps`` (commit F).

Args:
    task_id: Path parameter; the target task's primary key.
    authed: ``(Agent, AgentApiKey)`` tuple.
    db: SQLAlchemy session.

Returns:
    :class:`TaskInfoResponse` with ``task_id``, ``agent_id``,
    ``status``, latest-turn ``input`` / ``output`` / ``error``,
    ``created_at``, and ``completed_at`` (set only when the task
    has reached a terminal state).

Raises:
    V1ApiError 401: missing / invalid / revoked key.
    V1ApiError 404: task missing or not owned by the calling agent.

## Path parameters

- `task_id` integer, required

## Response `200`

Successful Response

- TaskInfoResponse — ``GET /v1/chat/tasks/{task_id}`` response. Returns a snapshot of the task's current state from the ``tasks`` row. ``input`` / ``output`` / ``error`` reflect the **latest** turn only -- full transcript history is queryable via the ``/steps`` endpoint's ``message`` type steps.
  - `task_id` integer, required
  - `agent_id` integer, required
  - `status` string, required — One of: pending / running / paused / completed / failed.
  - `input` string, nullable — Latest-turn user input. Null if no message yet recorded.
  - `output` string, nullable — Latest-turn assistant output. Populated when status reaches 'completed'; null while running or pending.
  - `error` string, nullable — Last failure reason when status='failed'.
  - `created_at` string, date-time, required
  - `completed_at` string, date-time, nullable — UTC timestamp when the task reached a terminal state (completed or failed). Null while still running.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/xorbitsai/apis/xagent.md) · [All operations](https://skmtc.net/xorbitsai/apis/xagent/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/xorbitsai/xagent/revisions/33e4ba4936ad/schema)
