削除バッチを取得
ドキュメントファイルを一括削除 のリクエストを、各ファイルの結果と、受け付けられた各ファイルの削除ジョブの現在の状態とともに返します。読み取れるのは、そのバッチを送信した API キーだけです。
results のすべてのエントリが rejected になるか、その job.run_state が completed または failed になれば、バッチは完了です。バッチを読み取っても、pending のファイルの処理が進むことはありません。pending のまま残ったファイルは、バッチが途中で停止した際に受け付けられなかったものです。これらを再試行するには、同じ Idempotency-Key で元のリクエストを再送信してください。
削除の流れについては、ドキュメントとソースの削除 を参照してください。
1 min read
get/knowledge-fs/spaces/{knowledge_base_id}/deletion-batches/{deletion_batch_id}
Request example
curl --request GET \
--url https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/deletion-batches/{deletion_batch_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/deletion-batches/{deletion_batch_id}"
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}/deletion-batches/{deletion_batch_id}', {
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}/deletion-batches/{deletion_batch_id}',
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}/deletion-batches/{deletion_batch_id}"
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}/deletion-batches/{deletion_batch_id}"))
.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}/deletion-batches/{deletion_batch_id}')
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
{
"batch_id": "3e5a7c9b-1d2f-4a6b-8c0d-2e4f6a8b0c1d",
"items": [
{
"document_id": "2c1e7a44-5b6d-4e8f-9a0b-1c2d3e4f5a6b",
"document_title": null,
"job": {
"checkpoint": "completed",
"completed_at": "2026-10-20T09:00:09Z",
"created_at": "2026-10-20T09:00:00Z",
"error": null,
"id": "b7e1c2d3-4f5a-4b6c-8d9e-0f1a2b3c4d5e",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"mode": "cascade",
"progress": null,
"retry_at": null,
"run_state": "completed",
"target_id": "2c1e7a44-5b6d-4e8f-9a0b-1c2d3e4f5a6b",
"target_type": "document",
"updated_at": "2026-10-20T09:00:09Z"
},
"status_url": "https://api.example.com/v1/knowledge-fs/spaces/8d2c6a1e-5b3f-4c7d-9e01-2a3b4c5d6e7f/deletion-jobs/b7e1c2d3-4f5a-4b6c-8d9e-0f1a2b3c4d5e"
},
{
"document_id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"document_title": null,
"job": {
"checkpoint": "deleting_derived_data",
"completed_at": null,
"created_at": "2026-10-20T09:00:00Z",
"error": null,
"id": "0c9d8e7f-6a5b-4c3d-9e2f-1a0b9c8d7e6f",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"mode": "cascade",
"progress": null,
"retry_at": null,
"run_state": "running",
"target_id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"target_type": "document",
"updated_at": "2026-10-20T09:00:04Z"
},
"status_url": "https://api.example.com/v1/knowledge-fs/spaces/8d2c6a1e-5b3f-4c7d-9e01-2a3b4c5d6e7f/deletion-jobs/0c9d8e7f-6a5b-4c3d-9e2f-1a0b9c8d7e6f"
}
],
"results": [
{
"document_id": "2c1e7a44-5b6d-4e8f-9a0b-1c2d3e4f5a6b",
"error": null,
"job": {
"checkpoint": "completed",
"completed_at": "2026-10-20T09:00:09Z",
"created_at": "2026-10-20T09:00:00Z",
"error": null,
"id": "b7e1c2d3-4f5a-4b6c-8d9e-0f1a2b3c4d5e",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"mode": "cascade",
"progress": null,
"retry_at": null,
"run_state": "completed",
"target_id": "2c1e7a44-5b6d-4e8f-9a0b-1c2d3e4f5a6b",
"target_type": "document",
"updated_at": "2026-10-20T09:00:09Z"
},
"status": "accepted",
"status_url": "https://api.example.com/v1/knowledge-fs/spaces/8d2c6a1e-5b3f-4c7d-9e01-2a3b4c5d6e7f/deletion-jobs/b7e1c2d3-4f5a-4b6c-8d9e-0f1a2b3c4d5e"
},
{
"document_id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"error": null,
"job": {
"checkpoint": "deleting_derived_data",
"completed_at": null,
"created_at": "2026-10-20T09:00:00Z",
"error": null,
"id": "0c9d8e7f-6a5b-4c3d-9e2f-1a0b9c8d7e6f",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"mode": "cascade",
"progress": null,
"retry_at": null,
"run_state": "running",
"target_id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"target_type": "document",
"updated_at": "2026-10-20T09:00:04Z"
},
"status": "accepted",
"status_url": "https://api.example.com/v1/knowledge-fs/spaces/8d2c6a1e-5b3f-4c7d-9e01-2a3b4c5d6e7f/deletion-jobs/0c9d8e7f-6a5b-4c3d-9e2f-1a0b9c8d7e6f"
},
{
"document_id": "9d8c7b6a-5f4e-4d3c-8b2a-1f0e9d8c7b6a",
"error": {
"code": "DURABLE_DELETION_NOT_FOUND",
"message": "Deletion request was rejected",
"retryable": false
},
"job": null,
"status": "rejected",
"status_url": null
}
],
"status_url": "https://api.example.com/v1/knowledge-fs/spaces/8d2c6a1e-5b3f-4c7d-9e01-2a3b4c5d6e7f/deletion-batches/3e5a7c9b-1d2f-4a6b-8c0d-2e4f6a8b0c1d",
"total": 3
}{
"code": "knowledge_fs_invalid_request",
"message": "Agent Knowledge Base request is invalid.",
"status": 400
}{
"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}/deletion-batches/{deletion_batch_id}
Authorization
すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401(unauthorized)で失敗します。
Path parameters
ナレッジベース ID です。ナレッジベースの API アクセス ダイアログに表示されるサービス API エンドポイントの最後のセグメント(
…/knowledge-fs/spaces/<knowledge base ID>)です。アドレスバーでは /datasets/new/ の後のセグメントです。Responses
application/json
バッチと、受け付けられた各ファイルのジョブの現在の状態です。
このリクエストを記録するバッチの ID です。
受け付けられたファイルごとに 1 つのエントリが入ります。
Show child attributesHide child attributes
ドキュメントファイル ID です。
ドキュメントファイルの削除では常に
null です。Show child attributesHide child attributes
削除の進み具合です。
requested(受け付け直後)から始まり、quiescing、deleting_objects、deleting_derived_data、deleting_primary_data、completed の順に進みます。ジョブの完了日時(ISO 8601)です。完了するまでの間と、
failed のジョブでは null です。ジョブが受け付けられた日時(ISO 8601)です。
直近のエラーです。エラーがない場合は
null です。run_state が retry_wait の間も設定されるため、ジョブが失敗したかどうかは error ではなく run_state で判断してください。削除ジョブ ID です。
ナレッジベースの内部 ID です。パスのナレッジベース ID とは異なります。
ソースの削除時に、そのソースのドキュメントをどう扱うかを示します。
cascade は削除し、keep は残します。ドキュメントファイルやドキュメントの削除では、この値は無視してください。複数アイテムの削除におけるアイテム数です。この API では設定されず、常に
null です。次回の自動再試行の実行日時(ISO 8601)です。予定されていない場合は
null です。スケジューラ上の状態です:
dispatch_pending(受け付け直後)、queued、running:処理中です。retry_wait:retry_atに自動再試行が予定されています。completed:すべて削除されました。failed:クリーンアップが停止し、対象は非表示のままです。再試行はできません。
対象の ID です。
document ではドキュメントファイル ID、logical_document ではドキュメント ID、source ではソース ID です。ジョブの削除対象です。ドキュメントファイルは
document、ドキュメント全体は logical_document、ソースは source です。ジョブが最後に変更された日時(ISO 8601)です。
リクエストされたファイルごとに 1 つのエントリが入り、その結果を示します。
Show child attributesHide child attributes
ドキュメントファイル ID です。
ファイルが拒否された理由です。それ以外の場合は
null です。status が accepted の場合の削除ジョブです。それ以外の場合は null です。Show child attributesHide child attributes
削除の進み具合です。
requested(受け付け直後)から始まり、quiescing、deleting_objects、deleting_derived_data、deleting_primary_data、completed の順に進みます。ジョブの完了日時(ISO 8601)です。完了するまでの間と、
failed のジョブでは null です。ジョブが受け付けられた日時(ISO 8601)です。
直近のエラーです。エラーがない場合は
null です。run_state が retry_wait の間も設定されるため、ジョブが失敗したかどうかは error ではなく run_state で判断してください。削除ジョブ ID です。
ナレッジベースの内部 ID です。パスのナレッジベース ID とは異なります。
ソースの削除時に、そのソースのドキュメントをどう扱うかを示します。
cascade は削除し、keep は残します。ドキュメントファイルやドキュメントの削除では、この値は無視してください。複数アイテムの削除におけるアイテム数です。この API では設定されず、常に
null です。次回の自動再試行の実行日時(ISO 8601)です。予定されていない場合は
null です。スケジューラ上の状態です:
dispatch_pending(受け付け直後)、queued、running:処理中です。retry_wait:retry_atに自動再試行が予定されています。completed:すべて削除されました。failed:クリーンアップが停止し、対象は非表示のままです。再試行はできません。
対象の ID です。
document ではドキュメントファイル ID、logical_document ではドキュメント ID、source ではソース ID です。ジョブの削除対象です。ドキュメントファイルは
document、ドキュメント全体は logical_document、ソースは source です。ジョブが最後に変更された日時(ISO 8601)です。
accepted:削除が受け付けられました。jobとstatus_urlが設定されます。rejected:ファイルは削除されていません。理由はerrorに示されます。pending:ファイルはまだ受け付けられていません。再試行するには、同じIdempotency-Keyで元のリクエストを再送信してください。
このバッチの 削除バッチを取得 の URL です。デプロイ環境で
SERVICE_API_URL が設定されている場合は絶対 URL、それ以外の場合は /v1/ で始まるパスです。ドキュメントファイルを一括削除 は、この値を Location レスポンスヘッダーでも返します。元のリクエストに含まれるファイル数です。