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

# 取消训练任务

> 取消仍处于 queued 或 running 的训练任务。返回 202 以及更新后的 job_id 与 status。

取消仍为 `queued` 或 `running` 的任务。其他状态返回 `409 Conflict`。成功后任务转为 `cancelled`，并在可能时退还预扣费用。

## 方法与路径

```http theme={null}
POST /v1/jobs/:id/cancel
```

## 认证

```http theme={null}
Authorization: Bearer <jwt-or-api-key>
```

## 路径参数

<ParamField path="id" type="string" required>
  任务标识符。
</ParamField>

## 请求体

无。

## 响应

返回 `202`：

```json theme={null}
{
  "code": 0,
  "data": {
    "job_id": "jb_abc123def456",
    "status": "cancelled"
  },
  "message": ""
}
```

## 示例

```bash theme={null}
curl -s -X POST http://localhost:8001/v1/jobs/jb_abc123def456/cancel \
  -H "Authorization: Bearer $PIN_API_TOKEN"
```

## 错误

| Code | HTTP | 含义                                |
| ---- | ---- | --------------------------------- |
| 401  | 401  | 缺失或无效的 Bearer 令牌。                 |
| 404  | 404  | 任务不存在或不属于你。                       |
| 409  | 409  | 当前状态不可取消（非 `queued` 或 `running`）。 |
