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

# Cancel Task

> POST /v1/tasks/{task_id}/cancel — Cancel a queued task

Cancel a task in the `queued` state. Quota is automatically refunded.

<Note>
  Only tasks in the `queued` state can be cancelled. Tasks in `processing` have
  already started and cannot be cancelled — the endpoint returns HTTP 400
  (`code: task_not_cancellable`). Queue turnaround is measured in seconds, so the
  cancellation window is small; callers should handle the 400 case. A cancelled
  task reports `cost: 0` when queried (quota refunded).
</Note>

## Response

```json theme={"system"}
{
  "task_id": "task_xxx",
  "status": "cancelled",
  "refunded": true,
  "refunded_quota": 50000
}
```

| Field            | Description                    |
| ---------------- | ------------------------------ |
| `refunded`       | Whether the quota was refunded |
| `refunded_quota` | Amount of quota refunded       |
