更新同步策略
设置数据源的定时同步,替换原有设置,并返回新设置。
保存不会启动同步。第一次定时同步在更新后满一个间隔时到期,之后每次在上一次进入队列后满一个间隔时到期。要立即同步,调用 同步数据源。
每次向该数据源导入完成后,都要用数据源新的 version 重新保存定时同步。导入会改变 version,仍绑定在旧值上的定时同步会在下一次到期时自行关闭。
要暂停定时同步而不改动其设置,用 更新数据源 将数据源的 status 设为 disabled。暂停期间到期的同步,会在数据源恢复为 active 时运行。
先读取再保存的流程,详见 同步数据源与定时同步。
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
Path Parameters
知识库 ID:即知识库 API 访问 对话框中所示服务 API 端点的最后一段(…/knowledge-fs/spaces/<knowledge base ID>),也是地址栏中 /datasets/new/ 之后的那一段。
Body
是否运行定时同步。mode: manual 时必须为 false。
manual 关闭定时同步,interval 每 24 小时同步一次,custom 按 customIntervalSeconds 的间隔同步。
manual, interval, custom 两次定时同步之间的秒数,取值为 1 小时~30 天。mode: custom 时必填,其他模式下传入会被拒绝。
3600 <= x <= 2592000Response
保存后的定时同步设置。mode: manual 或 enabled: false 时,next_run_at 为 null。
创建时间,ISO 8601 格式。
mode: custom 时的同步间隔,单位为秒。其他模式为 null。
是否运行定时同步。mode: manual 时始终为 false。
定时同步绑定的数据源 version。
同步策略 ID,更新后保持不变。
知识库的内部 ID,并非路径中的知识库 ID。
manual(不安排定时同步)、interval(每 24 小时)或 custom(按 custom_interval_seconds 的间隔)。
下次定时同步的时间,ISO 8601 格式。没有安排时为 null。
定时同步所属的数据源。
最后变更时间,ISO 8601 格式。定时同步开始时也会更新。
Was this page helpful?
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"
}