取消运行
curl --request POST \
--url https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancelimport requests
url = "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {method: 'POST'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_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://api-datahub.bazhuayu.com/v1/runs/{run_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://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel")
.post(null)
.build()
val response = client.newCall(request).execute()false{
"run_id": "<string>",
"namespace": "<string>",
"app_name": "<string>",
"app_version": "<string>",
"build_id": "<string>",
"run_kind": "<string>",
"state": {},
"input": {},
"progress": {
"done": 123,
"total": 123,
"status_text": "<string>"
},
"dataset_id": "<string>",
"partial": true,
"cancel_requested": true,
"triggered_by": "<string>",
"upstream_ref": "<string>",
"created_at": "<string>",
"started_at": "<string>",
"first_started_at": "<string>",
"finished_at": "<string>",
"usage": {
"metrics": {},
"duration_ms": 123
},
"billing": {
"events": [
{
"event": "<string>",
"label": "<string>",
"qty": 123,
"unit_price": 123,
"amount": 123,
"unit_size": 123,
"raw_qty": 123
}
],
"total": 123,
"currency": "<string>",
"charged": true
},
"error": {
"code": "<string>",
"category": "<string>",
"message": "<string>",
"retryable": true,
"retry_after": 123,
"item_index": 123,
"details": [
{}
]
},
"sample_records": [
{}
],
"warnings": [
{
"code": "<string>",
"event": "<string>",
"detail": {},
"count": 123,
"updated_at": "<string>"
}
]
}运行与结果
取消运行
取消排队或执行中的运行,已产出的记录保留。
POST
/
v1
/
runs
/
{run_id}
/
cancel
取消运行
curl --request POST \
--url https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancelimport requests
url = "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {method: 'POST'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_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://api-datahub.bazhuayu.com/v1/runs/{run_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://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel")
.post(null)
.build()
val response = client.newCall(request).execute()false{
"run_id": "<string>",
"namespace": "<string>",
"app_name": "<string>",
"app_version": "<string>",
"build_id": "<string>",
"run_kind": "<string>",
"state": {},
"input": {},
"progress": {
"done": 123,
"total": 123,
"status_text": "<string>"
},
"dataset_id": "<string>",
"partial": true,
"cancel_requested": true,
"triggered_by": "<string>",
"upstream_ref": "<string>",
"created_at": "<string>",
"started_at": "<string>",
"first_started_at": "<string>",
"finished_at": "<string>",
"usage": {
"metrics": {},
"duration_ms": 123
},
"billing": {
"events": [
{
"event": "<string>",
"label": "<string>",
"qty": 123,
"unit_price": 123,
"amount": 123,
"unit_size": 123,
"raw_qty": 123
}
],
"total": 123,
"currency": "<string>",
"charged": true
},
"error": {
"code": "<string>",
"category": "<string>",
"message": "<string>",
"retryable": true,
"retry_after": 123,
"item_index": 123,
"details": [
{}
]
},
"sample_records": [
{}
],
"warnings": [
{
"code": "<string>",
"event": "<string>",
"detail": {},
"count": 123,
"updated_at": "<string>"
}
]
}端点
POST https://api-datahub.bazhuayu.com/v1/runs/{run_id}/cancel
Authorization: Bearer <API Key>)。
下达取消信号并短暂等待(最多 5 秒)执行方响应,返回当前运行对象。排队中的运行立即停止;执行中的通常在数秒内协作停止。已经写回的记录保留(partial 为 true),可以照常读取,只按已产出的记录计费。
归属门与运行详情相同:只能取消自己发起的运行。取消后用查询运行确认终态。
请求
路径参数
string
必填
运行标识。
示例请求
curl -X POST \
-H "Authorization: Bearer $BAZHUAYU_API_KEY" \
"https://api-datahub.bazhuayu.com/v1/runs/run_c62bc0fb8df2/cancel"
响应
200 成功
{
"data": {
"run_id": "run_c62bc0fb8df2",
"namespace": "carol",
"app_name": "probe-b",
"app_version": "0.1.0",
"build_id": null,
"run_kind": "production",
"state": "SUCCEEDED",
"input": {
"product": "p-now"
},
"progress": {
"done": 20,
"total": null,
"status_text": null
},
"dataset_id": "ds_0bd5345d13d0",
"partial": false,
"cancel_requested": false,
"triggered_by": "api",
"upstream_ref": null,
"created_at": "2026-09-15T07:45:40.411993+00:00",
"started_at": "2026-09-15T07:45:40.419610+00:00",
"first_started_at": "2026-09-15T07:45:40.419610+00:00",
"finished_at": "2026-09-15T07:45:40.822250+00:00",
"usage": {
"metrics": {
"records_collected": 20
},
"duration_ms": 402
},
"billing": {
"events": [
{
"event": "record",
"label": "获取一条",
"qty": 20.0,
"unit_price": 0.001,
"amount": 0.02,
"unit_size": null,
"raw_qty": null
}
],
"total": 0.02,
"currency": "CNY",
"charged": true
},
"error": null,
"sample_records": null,
"warnings": []
}
}
data 字段中,其内容如下。
string
必填
—
string
—
string
—
string
—
string
—
string
—
enum
必填
取值:
PENDING / QUEUED / RUNNING / SUCCEEDED / PARTIALLY_SUCCEEDED / FAILED / CANCELLED / EXPIRED。object
—
string
—
boolean
—
boolean
true while cancellation has been requested and the run is still winding down (cooperative stop / partial-result recovery); always false in terminal states (normalized server-side), so consumers need not derive it from state
string
—
string
—
string
—
string
—
string
when the run was first claimed by a worker. Unlike started_at, which is re-stamped on every retry, this one is never rewritten, so it is the anchor for queue time: queued = first_started_at - created_at, and total wall time = finished_at - first_started_at. Deriving queue time from started_at counts the earlier attempts’ execution as queueing. Null only for runs never claimed.
string
—
object
object
object[]
—
错误
| HTTP | code | category | 说明 |
|---|---|---|---|
| 401 | unauthorized | forbidden | 缺少或无效的 API Key。 |
| 404 | run-not-found | not_found | 运行不存在,或不是当前账号发起的。 |
| 409 | run-terminal | invalid_input | 运行已经结束,无法取消。 |
{"error": {code, category, message, retryable}},见错误。
客户端库
run = client.cancel("run_c62bc0fb8df2")
print(run["state"], run["partial"])
const run = await client.cancel("run_c62bc0fb8df2");
console.log(run.state, run.partial);
