取消数据源运行
取消尚未结束的数据源运行,并返回该运行。
被取消的运行会在更新数据源的页面列表之前停止。运行已处理完的条目会保留到下一次同步,下一次同步会移除不在页面列表中的条目。导入时未包含的条目,其文档不会被删除,除非取消恰好发生在这些文档正被移除时。
已以 completed、zero_results 或 canceled 结束的运行,原样返回。
如何跟踪、重试和取消运行,详见 跟踪数据源运行。
curl --request POST \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "Preview not needed"
}
'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel"
payload = { "reason": "Preview not needed" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: 'Preview not needed'})
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{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",
CURLOPT_POSTFIELDS => json_encode([
'reason' => 'Preview not needed'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel"
payload := strings.NewReader("{\n \"reason\": \"Preview not needed\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Preview not needed\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"Preview not needed\"\n}"
response = http.request(request)
puts response.read_body{
"canceled_at": "2026-10-20T10:20:00Z",
"checkpoint": "preview-staged",
"completed_at": "2026-10-20T10:20:00Z",
"created_at": "2026-10-20T10:00:00Z",
"cursor": null,
"execution_attempts": 1,
"failure": null,
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"kind": "crawl-preview",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": null,
"max_execution_attempts": 5,
"progress_completed": 37,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": 37,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "canceled",
"updated_at": "2026-10-20T10:20:00Z"
}Authorizations
每个请求都通过 API 密钥认证:Authorization: Bearer {API_KEY}。应用接口使用应用 API 密钥,知识库接口使用知识库 API 密钥(快速开始)。
API 密钥应保存在服务端,切勿嵌入客户端代码。缺失或无效的密钥会返回 HTTP 401(unauthorized)。
Response
取消后的运行:state: canceled,canceled_at 和 completed_at 均已设置。
运行已到达的最后一步:queued、provider-read、preview-staged、selection-frozen、materialized、cleanup-staging 或 source-committed。无论运行停在哪个检查点,重试数据源运行 都会从头开始运行。
工作进程领取该运行的次数,包括 重试数据源运行 之后的领取,重试不会重置该值。
execution_attempts 的上限。达到上限后,重试数据源运行 返回 409。
运行预计处理的项数:导入请求的页面或条目数、抓取预览目前已暂存的页面数,或同步列出数据源条目后的条目数。确定之前为 null。
导入网站页面 的运行抓取 URL 期间,progress_completed 和 progress_total 都统计目前已抓取的页面数。所有 URL 抓取完成后,进度从 0 重新开始计,总数变为 URL 的数量。
Was this page helpful?
curl --request POST \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "Preview not needed"
}
'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel"
payload = { "reason": "Preview not needed" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: 'Preview not needed'})
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{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",
CURLOPT_POSTFIELDS => json_encode([
'reason' => 'Preview not needed'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel"
payload := strings.NewReader("{\n \"reason\": \"Preview not needed\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Preview not needed\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/source-workflows/{run_id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"Preview not needed\"\n}"
response = http.request(request)
puts response.read_body{
"canceled_at": "2026-10-20T10:20:00Z",
"checkpoint": "preview-staged",
"completed_at": "2026-10-20T10:20:00Z",
"created_at": "2026-10-20T10:00:00Z",
"cursor": null,
"execution_attempts": 1,
"failure": null,
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"kind": "crawl-preview",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": null,
"max_execution_attempts": 5,
"progress_completed": 37,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": 37,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "canceled",
"updated_at": "2026-10-20T10:20:00Z"
}