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

# 取消任务

> 取消进行中的任务

取消一个仍在队列中的任务。仅当任务状态为 `PENDING` 时可取消。一旦任务进入 `PROCESSING` 或 `SUBMITTED` 状态，将无法取消。

<ParamField path="taskId" type="string" required>
  要取消的任务 ID。
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.maxapi.io/api/v1/task/9db7d1ed-d1e5-4d11-9f3a-61f653b905ad/cancel \
    --header 'Authorization: Bearer <token>'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 0,
    "msg": "ok"
  }
  ```

  ```json 400 任务处理中 theme={null}
  {
    "code": 400,
    "msg": "task is already being processed"
  }
  ```

  ```json 400 任务已终态 theme={null}
  {
    "code": 400,
    "msg": "task already in terminal state"
  }
  ```

  ```json 404 theme={null}
  {
    "code": 404,
    "msg": "task not found"
  }
  ```
</ResponseExample>
