获取数据源运行列表
1 min read
get/knowledge-fs/spaces/{knowledge_base_id}/source-workflows
Request example
curl --request GET \
--url https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/source-workflows \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/source-workflows"
headers = {
"Authorization": "Bearer <token>",
}
response = requests.request("GET", url, headers=headers)
print(response.text)const response = await fetch('https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/source-workflows', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/source-workflows',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/source-workflows"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/source-workflows"))
.header("Authorization", "Bearer <token>")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/source-workflows')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Get.new(url)
request['Authorization'] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyResponse
{
"data": [
{
"canceled_at": null,
"checkpoint": "preview-staged",
"completed_at": "2026-10-18T07:41:09Z",
"created_at": "2026-10-18T07:40:00Z",
"cursor": null,
"execution_attempts": 1,
"failure": {
"action": "configure_source",
"category": "not_found",
"code": "SOURCE_CRAWL_PAGE_NOT_FOUND",
"message": "The requested Agent Knowledge Base resource was not found.",
"parameters": null,
"retryPolicy": "never",
"stage": "preview-staged",
"traceId": "d4c3b2a1-6f5e-4d7c-8b9a-0f1e2d3c4b5a"
},
"id": "d4c3b2a1-6f5e-4d7c-8b9a-0f1e2d3c4b5a",
"kind": "crawl-import",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": "SOURCE_CRAWL_PAGE_NOT_FOUND",
"max_execution_attempts": 5,
"progress_completed": 3,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": 3,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "failed",
"updated_at": "2026-10-18T07:41:09Z"
},
{
"canceled_at": null,
"checkpoint": "provider-read",
"completed_at": null,
"created_at": "2026-10-20T10:00:00Z",
"cursor": "ss1:eyJmaW5nZXJwcmludCI6ImNhOWE4YWUzMDljZTFiMzE5NzkyNTc3YzRmYjA4NGVhNzY1OGZiMzkzMjM1MGZlNzk2ZTdhNjEzM2Q4N2M4NzMiLCJraW5kIjoid2Vic2l0ZSIsIm9mZnNldCI6MTIsInBoYXNlIjoiaXRlbXMiLCJwcm9ncmVzc0NvbXBsZXRlZCI6MTIsInByb2dyZXNzVG90YWwiOjQ1fQ",
"execution_attempts": 1,
"failure": null,
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"kind": "sync",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": null,
"max_execution_attempts": 5,
"progress_completed": 12,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": 45,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "syncing",
"updated_at": "2026-10-20T10:02:40Z"
}
],
"next_cursor": null
}{
"code": "knowledge_fs_invalid_request",
"message": "Agent Knowledge Base request is invalid.",
"status": 400,
"violations": [
{
"field": [
"limit"
],
"type": "less_than_equal"
}
]
}{
"code": "knowledge_fs_invalid_request",
"failure": {
"category": "validation",
"code": "KNOWLEDGE_FS_INVALID_REQUEST",
"message": "The Agent Knowledge Base request is invalid.",
"retryPolicy": "never",
"traceId": "7f3c1a90-2e64-4b7d-8a51-6c0d9e2f4b83"
},
"message": "The Agent Knowledge Base request is invalid.",
"status": 400
}{
"code": "knowledge_fs_invalid_credential",
"message": "Invalid Agent Knowledge Base service credential.",
"status": 401
}{
"code": "unauthorized",
"message": "Access token is invalid",
"status": 401
}{
"code": "forbidden",
"message": "Sorry, you have reached the knowledge base request rate limit of your subscription.",
"status": 403
}{
"code": "knowledge_fs_access_denied",
"message": "Agent Knowledge Base operation is not allowed.",
"status": 403
}{
"code": "knowledge_fs_resource_not_found",
"failure": {
"category": "not_found",
"code": "KNOWLEDGE_FS_NOT_FOUND",
"message": "The requested Agent Knowledge Base resource was not found.",
"retryPolicy": "never",
"traceId": "7f3c1a90-2e64-4b7d-8a51-6c0d9e2f4b83"
},
"message": "The requested Agent Knowledge Base resource was not found.",
"status": 404
}{
"code": "not_found",
"message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"status": 404
}{
"code": "knowledge_fs_upstream_unavailable",
"failure": {
"action": "contact_admin",
"category": "internal",
"code": "KNOWLEDGE_FS_INTERNAL_ERROR",
"message": "Agent Knowledge Base could not complete the operation. Try again, or contact an administrator with the error reference.",
"retryPolicy": "manual",
"traceId": "5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b"
},
"message": "Agent Knowledge Base could not complete the operation. Try again, or contact an administrator with the error reference.",
"status": 502
}{
"code": "knowledge_fs_upstream_unavailable",
"message": "Agent Knowledge Base is unavailable.",
"status": 502
}{
"code": "knowledge_fs_operation_unavailable",
"message": "Agent Knowledge Base operation is not available.",
"status": 503
}{
"code": "knowledge_fs_operation_unavailable",
"failure": {
"action": "retry",
"category": "dependency",
"code": "KNOWLEDGE_FS_UNAVAILABLE",
"message": "A service required by Agent Knowledge Base is temporarily unavailable.",
"retryPolicy": "manual",
"traceId": "5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b"
},
"message": "A service required by Agent Knowledge Base is temporarily unavailable.",
"status": 503
}get/knowledge-fs/spaces/{knowledge_base_id}/source-workflows
Authorization
Path parameters
知识库 ID:即知识库 API 访问 对话框中所示服务 API 端点的最后一段(
…/knowledge-fs/spaces/<knowledge base ID>),也是地址栏中 /datasets/new/ 之后的那一段。Query parameters
Responses
application/json
一页运行。
本页的运行。
Show child attributesHide child attributes
取消运行的时间。仅当
state 为 canceled 时有值,否则为 null。运行已到达的最后一步:
queued、provider-read、preview-staged、selection-frozen、materialized、cleanup-staging 或 source-committed。无论运行停在哪个检查点,重试数据源运行 都会从头开始运行。运行结束(
completed、zero_results、failed 或 canceled)的时间,ISO 8601 格式。运行期间为 null。创建时间,ISO 8601 格式。
运行恢复时所用的提供商游标。运行尚未翻页时为
null。state 为 failed 时的错误详情。其中 stage 为失败时运行的 checkpoint,traceId 为运行 ID。其他情况下为 null。Show child attributesHide child attributes
建议的下一步操作(如有):
configure_model、configure_parser、configure_source、contact_admin、reupload 或 retry。不适用时为 null。HTTP 错误响应体中不包含此字段。失败类别:
authorization、canceled、configuration、conflict、dependency、internal、not_found、rate_limit、timeout 或 validation。稳定的错误码,采用大写蛇形命名,例如
KNOWLEDGE_FS_CONFLICT 或 SOURCE_CREDENTIAL_TEST_FAILED。错误码或失败类别对应的公开消息。不会暴露提供商的错误详情。
描述失败细节的值,最多 8 个,键取自
attempt、currentRowVersion、documentCount、expectedRowVersion、fileSizeBytes、limit、maxFileSizeBytes、maxItems、modelType、providerKind、retryAfterSeconds 和 status。没有时为 null。HTTP 错误响应体中不包含此字段。重试是否有用:
automatic(服务会自动重试)、manual(需自行重试)、after_configuration(先在 Dify 中修正知识库配置)或 never(需修改请求)。失败所在的阶段,例如
query_generation 或 credential-test。不适用时为 null。HTTP 错误响应体中不包含此字段。联系管理员时需提供的参考编号。在包含失败详情的成功响应中可能为
null,在 HTTP 错误响应体中可能不出现。知识库的内部 ID,并非路径中的知识库 ID。
state 为 failed 时为 failure.code 的值,否则为 null。已处理完的项数,包括同步时检查过但未变化的项。
数据源运行始终为
0:任一项失败都会导致整个运行失败。数据源运行始终为
0。运行预计处理的项数:导入请求的页面或条目数、抓取预览目前已暂存的页面数,或同步列出数据源条目后的条目数。确定之前为 null。
导入网站页面 的运行抓取 URL 期间,progress_completed 和 progress_total 都统计目前已抓取的页面数。所有 URL 抓取完成后,进度从 0 重新开始计,总数变为 URL 的数量。
运行所属的数据源。
最后变更时间,ISO 8601 格式。
下一页的游标,最后一页时为
null。将其作为 cursor 传回。