インデックスタスク
バックグラウンドタスク一覧を取得
ナレッジベースのバックグラウンド処理を 1 つのフィードにまとめて一覧表示するか、特定のタスクを ID で検索します:
task_idsなし:最新のインデックスタスク、一括タスク、ソースの実行を、新しい順にまとめて返します。一括タスクに属するインデックスタスクは、その一括タスクとして表示されます。ただし、コンテンツはすでに使用中で、ナレッジグラフがまだ構築中か構築に失敗した場合は除きます。古いタスクはnext_cursorをたどって取得します。task_idsあり:最大 100 件のインデックスタスク ID または一括タスク ID を指定します。不明な ID、API キーから見えないタスク、ソースの実行の ID は除外されます。このリストはページ分割されません。
ドキュメントを再インデックス のリクエストをここで追跡するには、その bulk_job_id を検索します。
どの場面でどのタスク操作を使うかについては、インデックス処理の追跡 を参照してください。
GET
/
knowledge-fs
/
spaces
/
{knowledge_base_id}
/
background-tasks
バックグラウンドタスク一覧を取得
curl --request GET \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks \
--header 'Authorization: Bearer <token>'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks"
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))
}HttpResponse<String> response = Unirest.get("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"can_cancel": true,
"can_retry": false,
"completed_at": null,
"created_at": "2026-10-20T10:00:00Z",
"document_id": null,
"document_revision": null,
"document_title": null,
"error_code": null,
"error_message": null,
"failure": null,
"failures": null,
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"operation": "source_sync",
"progress_completed": 12,
"progress_failed": 0,
"progress_percent": 27,
"progress_total": 45,
"semantic_enrichment": null,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"source_title": "Docs site",
"state": "running",
"task_kind": "source",
"updated_at": "2026-10-20T10:02:40Z"
},
{
"can_cancel": true,
"can_retry": false,
"completed_at": null,
"created_at": "2026-10-20T09:30:00Z",
"document_id": null,
"document_revision": null,
"document_title": null,
"error_code": null,
"error_message": null,
"failure": null,
"failures": null,
"id": "c7d9e1f3-5a7b-4c9d-8e0f-1a2b3c4d5e6f",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"operation": "document_reindex",
"progress_completed": 1,
"progress_failed": 0,
"progress_percent": 50,
"progress_total": 2,
"semantic_enrichment": null,
"source_id": null,
"source_title": null,
"state": "running",
"task_kind": "document_bulk",
"updated_at": "2026-10-20T09:31:12Z"
},
{
"can_cancel": false,
"can_retry": false,
"completed_at": "2026-10-20T08:16:05Z",
"created_at": "2026-10-20T08:15:42Z",
"document_id": "2f6b8d1a-7c3e-4a5b-9d0e-1f2a3b4c5d6e",
"document_revision": 2,
"document_title": null,
"error_code": null,
"error_message": null,
"failure": null,
"failures": null,
"id": "c4e8a2f6-1b3d-4e5f-8a9b-0c1d2e3f4a5b",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"operation": "document_processing",
"progress_completed": 1,
"progress_failed": 0,
"progress_percent": 100,
"progress_total": 1,
"semantic_enrichment": {
"error_code": null,
"error_message": null,
"failure": null,
"nodes_completed": 18,
"nodes_total": 18,
"provider_calls": 12,
"provider_calls_maximum": 200,
"state": "ready",
"updated_at": "2026-10-20T08:17:30Z"
},
"source_id": null,
"source_title": null,
"state": "completed",
"task_kind": "document",
"updated_at": "2026-10-20T08:17:30Z"
}
],
"next_cursor": "eyJ2ZXJzaW9uIjoxLCJzb3VyY2UiOnsiY3JlYXRlZEF0IjoiMjAyNi0xMC0yMFQxMDowMDowMC4wMDBaIiwiaWQiOiJlMWYyYTNiNC1jNWQ2LTRlN2YtOGE5Yi0wYzFkMmUzZjRhNWIifSwiYnVsayI6eyJjcmVhdGVkQXQiOiIyMDI2LTEwLTIwVDA5OjMwOjAwLjAwMFoiLCJpZCI6ImM3ZDllMWYzLTVhN2ItNGM5ZC04ZTBmLTFhMmIzYzRkNWU2ZiJ9LCJkb2N1bWVudCI6eyJjcmVhdGVkQXQiOiIyMDI2LTEwLTIwVDA4OjE1OjQyLjAwMFoiLCJpZCI6ImM0ZThhMmY2LTFiM2QtNGU1Zi04YTliLTBjMWQyZTNmNGE1YiJ9fQ"
}Authorizations
すべてのリクエストは 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/ の後のセグメントです。
Query Parameters
検索するインデックスタスク ID または一括タスク ID をカンマ区切りで指定します(最大 100 件)。cursor とは併用できません。
Maximum string length:
3699Pattern:
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(,[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}){0,99}$前のページの next_cursor から取得したカーソルです。task_ids と同時には指定できません。
Required string length:
1 - 81921 ページあたりのタスク数です。task_ids を指定した場合は無視されます。
Required range:
1 <= x <= 100Was this page helpful?
⌘I
バックグラウンドタスク一覧を取得
curl --request GET \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks \
--header 'Authorization: Bearer <token>'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks"
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))
}HttpResponse<String> response = Unirest.get("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/background-tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"can_cancel": true,
"can_retry": false,
"completed_at": null,
"created_at": "2026-10-20T10:00:00Z",
"document_id": null,
"document_revision": null,
"document_title": null,
"error_code": null,
"error_message": null,
"failure": null,
"failures": null,
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"operation": "source_sync",
"progress_completed": 12,
"progress_failed": 0,
"progress_percent": 27,
"progress_total": 45,
"semantic_enrichment": null,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"source_title": "Docs site",
"state": "running",
"task_kind": "source",
"updated_at": "2026-10-20T10:02:40Z"
},
{
"can_cancel": true,
"can_retry": false,
"completed_at": null,
"created_at": "2026-10-20T09:30:00Z",
"document_id": null,
"document_revision": null,
"document_title": null,
"error_code": null,
"error_message": null,
"failure": null,
"failures": null,
"id": "c7d9e1f3-5a7b-4c9d-8e0f-1a2b3c4d5e6f",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"operation": "document_reindex",
"progress_completed": 1,
"progress_failed": 0,
"progress_percent": 50,
"progress_total": 2,
"semantic_enrichment": null,
"source_id": null,
"source_title": null,
"state": "running",
"task_kind": "document_bulk",
"updated_at": "2026-10-20T09:31:12Z"
},
{
"can_cancel": false,
"can_retry": false,
"completed_at": "2026-10-20T08:16:05Z",
"created_at": "2026-10-20T08:15:42Z",
"document_id": "2f6b8d1a-7c3e-4a5b-9d0e-1f2a3b4c5d6e",
"document_revision": 2,
"document_title": null,
"error_code": null,
"error_message": null,
"failure": null,
"failures": null,
"id": "c4e8a2f6-1b3d-4e5f-8a9b-0c1d2e3f4a5b",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"operation": "document_processing",
"progress_completed": 1,
"progress_failed": 0,
"progress_percent": 100,
"progress_total": 1,
"semantic_enrichment": {
"error_code": null,
"error_message": null,
"failure": null,
"nodes_completed": 18,
"nodes_total": 18,
"provider_calls": 12,
"provider_calls_maximum": 200,
"state": "ready",
"updated_at": "2026-10-20T08:17:30Z"
},
"source_id": null,
"source_title": null,
"state": "completed",
"task_kind": "document",
"updated_at": "2026-10-20T08:17:30Z"
}
],
"next_cursor": "eyJ2ZXJzaW9uIjoxLCJzb3VyY2UiOnsiY3JlYXRlZEF0IjoiMjAyNi0xMC0yMFQxMDowMDowMC4wMDBaIiwiaWQiOiJlMWYyYTNiNC1jNWQ2LTRlN2YtOGE5Yi0wYzFkMmUzZjRhNWIifSwiYnVsayI6eyJjcmVhdGVkQXQiOiIyMDI2LTEwLTIwVDA5OjMwOjAwLjAwMFoiLCJpZCI6ImM3ZDllMWYzLTVhN2ItNGM5ZC04ZTBmLTFhMmIzYzRkNWU2ZiJ9LCJkb2N1bWVudCI6eyJjcmVhdGVkQXQiOiIyMDI2LTEwLTIwVDA4OjE1OjQyLjAwMFoiLCJpZCI6ImM0ZThhMmY2LTFiM2QtNGU1Zi04YTliLTBjMWQyZTNmNGE1YiJ9fQ"
}