Get Deletion Batch
Returns a Delete Document Files in Batch request with each file’s outcome and the current state of each accepted file’s deletion job. Only the API key that sent the batch can read it.
The batch is done when every entry in results is rejected or its job.run_state is completed or failed. Reading the batch never moves a pending file forward. Files left pending weren’t accepted when the batch stopped partway. To retry them, send the original request again with the same Idempotency-Key.
For the deletion flow, see Delete Documents and Sources.
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_body{
"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
}Authorization
Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).
Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).
Path parameters
…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.Responses
Show child attributesHide child attributes
null for document file deletions.Show child attributesHide child attributes
requested (newly accepted), then quiescing, deleting_objects, deleting_derived_data, deleting_primary_data, and completed.null until then, and on a failed job.null when there is none. It is also set while run_state is retry_wait, so read run_state, not error, to tell whether the job failed.cascade deletes them, keep keeps them. Ignore it on a deletion of a document file or a document.null.null when none is scheduled.Scheduler state:
dispatch_pending(newly accepted),queued,running: in progress.retry_wait: an automatic retry is scheduled atretry_at.completed: everything was removed.failed: cleanup stopped, and the target stays hidden. It can't be retried.
document, the document ID for logical_document, the source ID for source.document for a document file, logical_document for a whole document, source for a source.Show child attributesHide child attributes
null otherwise.status is accepted. null otherwise.Show child attributesHide child attributes
requested (newly accepted), then quiescing, deleting_objects, deleting_derived_data, deleting_primary_data, and completed.null until then, and on a failed job.null when there is none. It is also set while run_state is retry_wait, so read run_state, not error, to tell whether the job failed.cascade deletes them, keep keeps them. Ignore it on a deletion of a document file or a document.null.null when none is scheduled.Scheduler state:
dispatch_pending(newly accepted),queued,running: in progress.retry_wait: an automatic retry is scheduled atretry_at.completed: everything was removed.failed: cleanup stopped, and the target stays hidden. It can't be retried.
document, the document ID for logical_document, the source ID for source.document for a document file, logical_document for a whole document, source for a source.accepted: deletion was accepted, andjobandstatus_urlare set.rejected: the file was not deleted.errorsays why.pending: the file was not accepted yet. To retry it, send the original request again with the sameIdempotency-Key.
SERVICE_API_URL, otherwise a path that starts with /v1/. Delete Document Files in Batch also sends it in the Location response header.