跳转到主要内容
POST
/
v1
/
tasks
/
{task_id}
/
cancel
取消任务
curl --request POST \
  --url https://www.qingbo.dev/v1/tasks/{task_id}/cancel
import requests

url = "https://www.qingbo.dev/v1/tasks/{task_id}/cancel"

response = requests.post(url)

print(response.text)
const options = {method: 'POST'};

fetch('https://www.qingbo.dev/v1/tasks/{task_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://www.qingbo.dev/v1/tasks/{task_id}/cancel"

req, _ := http.NewRequest("POST", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://www.qingbo.dev/v1/tasks/{task_id}/cancel")
.asString();
取消一个处于 queued 状态的任务,配额自动退还。
只有 queued 状态的任务可以取消。processing 状态的任务已经开始处理,无法取消—— 此时返回 HTTP 400(code: task_not_cancellable)。队列流转是秒级的,取消窗口很小, 调用方应兜住 400 的情况。已取消的任务查询时 cost0(配额已退还)。

响应

{
  "task_id": "task_xxx",
  "status": "cancelled",
  "refunded": true,
  "refunded_quota": 50000
}
字段说明
refunded是否已退还配额
refunded_quota退还的配额数量