数据源
更新同步策略
设置数据源的定时同步,替换原有设置,并返回新设置。
保存不会启动同步。第一次定时同步在更新后满一个间隔时到期,之后每次在上一次进入队列后满一个间隔时到期。要立即同步,调用 同步数据源。
每次向该数据源导入完成后,都要用数据源新的 version 重新保存定时同步。导入会改变 version,仍绑定在旧值上的定时同步会在下一次到期时自行关闭。
要暂停定时同步而不改动其设置,用 更新数据源 将数据源的 status 设为 disabled。暂停期间到期的同步,会在数据源恢复为 active 时运行。
先读取再保存的流程,详见 同步数据源与定时同步。
PUT
/
knowledge-fs
/
spaces
/
{knowledge_base_id}
/
sources
/
{source_id}
/
sync-policy
curl --request PUT \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/sync-policy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customIntervalSeconds": 21600,
"enabled": true,
"expectedRevision": 5,
"expectedSourceVersion": 8,
"mode": "custom"
}
'{
"created_at": "2026-09-01T08:05:00Z",
"custom_interval_seconds": 21600,
"enabled": true,
"expected_source_version": 8,
"id": "8e7d6c5b-4a39-4f28-9e17-0d1c2b3a4f5e",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"mode": "custom",
"next_run_at": "2026-10-21T08:30:00Z",
"revision": 6,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"updated_at": "2026-10-21T02:30:00Z"
}Authorizations
每个请求都通过 API 密钥认证:Authorization: Bearer {API_KEY}。应用接口使用应用 API 密钥,知识库接口使用知识库 API 密钥(快速开始)。
API 密钥应保存在服务端,切勿嵌入客户端代码。缺失或无效的密钥会返回 HTTP 401(unauthorized)。
Body
application/json
定时同步当前的 revision,取自 获取同步策略。数据源尚无定时同步时传 0。每次定时同步启动时该值也会递增,因此应在更新前立即读取。值已过时则返回 409,不做任何更改。
Required range:
x >= 0Response
保存后的定时同步设置。mode: manual 或 enabled: false 时,next_run_at 为 null。
定时同步的修订版本。调用 更新同步策略 时将其作为 expectedRevision 传入。每次更新以及每次定时同步开始时都会递增。
Was this page helpful?
⌘I
curl --request PUT \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/sync-policy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customIntervalSeconds": 21600,
"enabled": true,
"expectedRevision": 5,
"expectedSourceVersion": 8,
"mode": "custom"
}
'{
"created_at": "2026-09-01T08:05:00Z",
"custom_interval_seconds": 21600,
"enabled": true,
"expected_source_version": 8,
"id": "8e7d6c5b-4a39-4f28-9e17-0d1c2b3a4f5e",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"mode": "custom",
"next_run_at": "2026-10-21T08:30:00Z",
"revision": 6,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"updated_at": "2026-10-21T02:30:00Z"
}