> ## 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.

# 取消任务

> POST /v1/tasks/{task_id}/cancel — 取消排队中的任务

取消一个处于 `queued` 状态的任务，配额自动退还。

<Note>
  只有 `queued` 状态的任务可以取消。`processing` 状态的任务已经开始处理，无法取消——
  此时返回 HTTP 400（`code: task_not_cancellable`）。队列流转是秒级的，取消窗口很小，
  调用方应兜住 400 的情况。已取消的任务查询时 `cost` 为 `0`（配额已退还）。
</Note>

## 响应

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

| 字段               | 说明      |
| ---------------- | ------- |
| `refunded`       | 是否已退还配额 |
| `refunded_quota` | 退还的配额数量 |
