ドキュメントのアウトラインを取得
ドキュメントファイルの現在のバージョンについて構築された見出しツリーを返します。
アウトラインは、インデックス処理で構築された後にのみ存在します。その段階より前にインデックス処理が失敗したファイルには、アウトラインはありません。再インデックスした場合は、新しいインデックスタスクの公開が済むと、そのタスクが構築したアウトラインを返します。
レスポンスはページ分割されません。
1 min read
get/knowledge-fs/spaces/{knowledge_base_id}/documents/{document_file_id}/outline
Request example
curl --request GET \
--url https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/documents/{document_file_id}/outline \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/documents/{document_file_id}/outline"
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}/documents/{document_file_id}/outline', {
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}/documents/{document_file_id}/outline',
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}/documents/{document_file_id}/outline"
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}/documents/{document_file_id}/outline"))
.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}/documents/{document_file_id}/outline')
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
{
"artifact_hash": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
"created_at": "2026-09-03T10:04:00Z",
"document_asset_id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"id": "c9d8e7f6-a5b4-4c3d-8e2f-1a0b9c8d7e6f",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"metadata": {},
"nodes": [
{
"child_node_ids": [
"n-1-1"
],
"children": [
{
"child_node_ids": [],
"children": [],
"end_offset": 4210,
"end_page": 3,
"id": "n-1-1",
"level": 2,
"metadata": {},
"section_path": [
"1 Introduction",
"1.1 Scope"
],
"source_element_ids": [
"el-12"
],
"source_node_ids": [],
"start_offset": 2100,
"start_page": 2,
"summary": null,
"title": "1.1 Scope",
"title_location": null,
"toc_source": "parser-heading"
}
],
"end_offset": 9800,
"end_page": 6,
"id": "n-1",
"level": 1,
"metadata": {},
"section_path": [
"1 Introduction"
],
"source_element_ids": [
"el-3"
],
"source_node_ids": [],
"start_offset": 0,
"start_page": 1,
"summary": null,
"title": "1 Introduction",
"title_location": null,
"toc_source": "parser-heading"
}
],
"outline_version": "document-outline-v1",
"parse_artifact_id": "d1e2f3a4-b5c6-4d7e-8f90-a1b2c3d4e5f6",
"updated_at": null,
"version": 1
}{
"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_request",
"message": "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_access_denied",
"failure": {
"action": "contact_admin",
"category": "authorization",
"code": "KNOWLEDGE_FS_ACCESS_DENIED",
"message": "You do not have permission to perform this Agent Knowledge Base operation.",
"retryPolicy": "never",
"traceId": "7f3c1a90-2e64-4b7d-8a51-6c0d9e2f4b83"
},
"message": "You do not have permission to perform this Agent Knowledge Base operation.",
"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}/documents/{document_file_id}/outline
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/ の後のセグメントです。ドキュメントファイル ID です。ドキュメントファイル一覧を取得 から取得します。
Responses
application/json
アウトラインです。
内部用です。アウトラインの読み取りには不要です。
アウトラインが構築された日時(ISO 8601)です。
アウトラインの構築対象となったドキュメントファイルの ID です。
アウトライン ID です。
ナレッジベースの内部 ID です。パスのナレッジベース ID とは異なります。
アウトラインの追加情報です。自由形式のオブジェクトです。
最上位の見出しです。ドキュメント内の順に並びます。下位の見出しは、各見出しの
children に入ります。Show child attributesHide child attributes
children に含まれる見出しの ID です。解析済みドキュメントテキスト内の 0 始まりの UTF-8 バイトオフセットです。終了位置を表し、この位置自体は範囲に含みません。不明な場合は
null です。セクションの最終ページで、
1 から数えます。ファイルにページがない場合は null です。見出し ID です。
見出しの階層の深さで、
1 から始まります。見出しの追加情報です。自由形式のオブジェクトです。
ドキュメントのルートからこの見出しまでの見出しです。この見出し自体も含みます。
見出しの検出元となった解析済み要素の ID です。
内部用です。アウトラインの読み取りには不要です。
解析済みドキュメントテキスト内の 0 始まりの UTF-8 バイトオフセットです。開始位置を表し、この位置自体を範囲に含みます。不明な場合は
null です。セクションの最初のページで、
1 から数えます。ファイルにページがない場合は null です。生成されたセクションの要約です。生成されていない場合は
null です。見出しのテキストです。
ファイル内での見出しの位置です。不明な場合は
null です。見出しの検出方法で、
native-toc、llm-inferred、parser-heading、fallback のいずれかです。内部用です。アウトラインの読み取りには不要です。
内部用です。アウトラインの読み取りには不要です。
アウトラインが最後に変更された日時(ISO 8601)です。構築後に変更されていない場合は
null です。アウトラインが属するドキュメントファイルの
version です。ドキュメントファイルの version は変わらないため、再インデックスでアウトラインが再構築されても、この値は変わりません。