Skip to main content
GET
获取批量任务

Authorizations

Authorization
string
header
required

每个请求都通过 API Key 认证:Authorization: Bearer {API_KEY}。应用接口使用应用 API Key,知识库接口使用知识库 API Key(快速开始)。

API Key 应保存在服务端,切勿嵌入客户端代码。缺失或无效的 Key 会返回 HTTP 401(unauthorized)。

Path Parameters

knowledge_base_id
string<uuid>
required

知识库 ID:即知识库 API 访问 对话框中所示服务 API 端点的最后一段(…/knowledge-fs/spaces/<knowledge base ID>),也是地址栏中 /datasets/new/ 之后的那一段。

bulk_task_id
string<uuid>
required

批量任务 ID:重新索引文档 响应中的 bulk_job_id。获取后台任务列表 也会返回该 ID,即 document_bulk 任务的 id。

Response

批量任务。

canceled_items
integer

任务已取消的条目数,包括请求重新索引时已禁用的文档。

completed_items
integer

已完成或被报告为 not_found 的条目数。

created_at
string

批量任务的创建时间,ISO 8601 格式。

failed_item_ids
string[]

失败条目的 ID,即提交给 重新索引文档 时的 ID。它们不是索引任务 ID。可借助你从该响应中保留的 items 条目,将它们对应到具体任务。

failed_items
integer

任务失败的条目数。

failures
object[]

每个失败条目对应一项。没有失败时为空。

id
string

批量任务 ID。

knowledge_space_id
string

知识库的内部 ID,并非路径中的知识库 ID。

status
string

汇总状态:

  • running:至少有一个条目仍在进行中。
  • completed:每个条目都已完成(至少到达 projection_built,该阶段在 published 之前)或被报告为 not_found。
  • failed:每个条目都已进入终态,且至少有一个失败。
  • canceled:每个条目都已进入终态,没有失败,且至少有一个被取消。

completed 不能保证新的修订版本已经生效。如果这一点很重要,用你从 重新索引文档 保留的任务 ID,通过 获取索引任务 逐个检查任务是否为 stage: published。

total_items
integer

提交的条目数。

type
string

来自此 API 的批量任务为 document_reindex。document_upload 和 document_delete 只会由 Dify 中的操作产生。通过此 API 删除时,返回的是删除作业,而不是批量任务:通过 获取删除作业 或 获取删除批次 跟踪。

updated_at
string

批量任务及其索引任务中最近一次变更的时间,ISO 8601 格式。