> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Document Outline

> Returns the heading tree built for the current version of a document file.

The outline exists only after indexing has built it, and not at all for a file whose indexing failed before that step. After a re-index, this operation returns the outline the new indexing task built, once that task publishes.

The response is not paginated.



## OpenAPI

````yaml /en/api-reference/openapi_service.json get /knowledge-fs/spaces/{knowledge_base_id}/documents/{document_file_id}/outline
openapi: 3.0.1
info:
  description: >-
    REST API for Dify applications and knowledge bases. Application endpoints
    authenticate with an app API key; knowledge endpoints authenticate with a
    dataset API key.
  title: Dify Service API
  version: 1.0.0
servers:
  - description: >-
      Base URL of the Dify Service API. For self-hosted deployments, replace it
      with your own API base URL.
    url: https://{api_base_url}
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: Host and path of the API base URL, without the `https://` prefix.
security:
  - ApiKeyAuth: []
tags:
  - description: Operations related to chat messages and interactions.
    name: Chat Messages
  - description: File upload and preview operations.
    name: Files
  - description: Operations related to end user information.
    name: End Users
  - description: User feedback operations.
    name: Feedback
  - description: Operations related to managing conversations.
    name: Conversations
  - description: Text-to-Speech and Speech-to-Text operations.
    name: Audio
  - description: Operations to retrieve application settings and information.
    name: Applications
  - description: Operations related to managing annotations for direct replies.
    name: Annotations
  - description: Endpoints for resuming paused workflows that require human input.
    name: Human Input
  - description: Operations for executing and managing workflows.
    name: Workflow Runs
  - description: Operations related to text generation and completion.
    name: Completion Messages
  - description: >-
      Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
    name: Knowledge Bases
  - description: >-
      Operations for creating, updating, and managing documents within a
      knowledge base.
    name: Documents
  - description: Operations for managing document chunks and child chunks.
    name: Chunks
  - description: >-
      Operations for managing knowledge base metadata fields and document
      metadata values.
    name: Metadata
  - description: Operations for managing knowledge base tags and tag bindings.
    name: Tags
  - description: Operations for retrieving available models.
    name: Models
  - description: >-
      Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
    name: Knowledge Pipeline
  - description: Ask a knowledge base a question and stream the answer.
    name: Queries
  - description: Inspect what a query retrieved and why.
    name: Query Records
  - description: Run a research question in the background and collect its results.
    name: Research Tasks
  - description: >-
      Read the documents in a knowledge base, their files, revisions, and
      chunks; label documents with metadata.
    name: Documents and Chunks
  - description: >-
      Follow, cancel, or retry indexing, and list the knowledge base's
      background tasks.
    name: Indexing Tasks
  - description: >-
      Follow the deletion of a document file, a batch of files, or a source
      until it finishes.
    name: Deletion Jobs
  - description: >-
      Manage the sources that feed a knowledge base, their sync schedules, and
      their connections.
    name: Sources
  - description: >-
      Sync a source now, import website pages or provider items, and follow,
      cancel, or retry the runs.
    name: Source Syncs and Imports
  - description: >-
      Read and change the knowledge base's models and retrieval settings, and
      follow the migration a change starts.
    name: Settings
paths:
  /knowledge-fs/spaces/{knowledge_base_id}/documents/{document_file_id}/outline:
    get:
      tags:
        - Documents and Chunks
      summary: Get Document Outline
      description: >-
        Returns the heading tree built for the current version of a document
        file.


        The outline exists only after indexing has built it, and not at all for
        a file whose indexing failed before that step. After a re-index, this
        operation returns the outline the new indexing task built, once that
        task publishes.


        The response is not paginated.
      operationId: getDocumentOutline
      parameters:
        - description: >-
            Knowledge base ID: the last segment of the Service API endpoint
            shown in the knowledge base's **API Access** dialog
            (`…/knowledge-fs/spaces/<knowledge base ID>`), and the segment after
            `/datasets/new/` in the address bar.
          in: path
          name: knowledge_base_id
          required: true
          schema:
            format: uuid
            type: string
        - description: >-
            Document file ID. From [List Document
            Files](/en/api-reference/documents-and-chunks/list-document-files).
          in: path
          name: document_file_id
          required: true
          schema:
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              examples:
                success:
                  summary: Response Example
                  value:
                    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
              schema:
                properties:
                  artifact_hash:
                    description: Internal. Not needed to read the outline.
                    type: string
                  created_at:
                    description: When the outline was built, ISO 8601.
                    type: string
                  document_asset_id:
                    description: ID of the document file the outline was built for.
                    type: string
                  id:
                    description: Outline ID.
                    type: string
                  knowledge_space_id:
                    description: >-
                      Internal ID of the knowledge base. Not the knowledge base
                      ID in the path.
                    type: string
                  metadata:
                    additionalProperties: true
                    description: Additional outline details. Free-form object.
                    type: object
                  nodes:
                    description: >-
                      Top-level headings, in document order. Nested headings are
                      in each heading's `children`.
                    items:
                      $ref: '#/components/schemas/KnowledgeBaseOutlineHeading'
                    type: array
                  outline_version:
                    description: Internal. Not needed to read the outline.
                    type: string
                  parse_artifact_id:
                    description: Internal. Not needed to read the outline.
                    type: string
                  updated_at:
                    description: >-
                      When the outline last changed, ISO 8601. `null` when it
                      has not changed since it was built.
                    nullable: true
                    type: string
                  version:
                    description: >-
                      The document file's `version` the outline belongs to. It
                      does not change when a re-index rebuilds the outline,
                      because a document file's `version` never changes.
                    type: integer
                type: object
          description: The outline.
        '400':
          content:
            application/json:
              examples:
                knowledge_fs_invalid_request:
                  summary: knowledge_fs_invalid_request
                  value:
                    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
                knowledge_fs_invalid_request_path:
                  summary: knowledge_fs_invalid_request (path ID)
                  value:
                    code: knowledge_fs_invalid_request
                    message: Agent Knowledge Base request is invalid.
                    status: 400
          description: |-
            - `knowledge_fs_invalid_request`: `document_file_id` is not a UUID.
            - `knowledge_fs_invalid_request`: `document_file_id` is malformed.
        '401':
          content:
            application/json:
              examples:
                knowledge_fs_invalid_credential:
                  summary: knowledge_fs_invalid_credential
                  value:
                    code: knowledge_fs_invalid_credential
                    message: Invalid Agent Knowledge Base service credential.
                    status: 401
                unauthorized:
                  summary: unauthorized
                  value:
                    code: unauthorized
                    message: Access token is invalid
                    status: 401
          description: >-
            - `unauthorized`: the `Authorization` header is missing, or the key
            is unknown or not a knowledge base API key.

            - `knowledge_fs_invalid_credential`: the key is valid, but no
            knowledge base with this ID exists in the key's workspace, or the
            key is not tied to a workspace.
        '403':
          content:
            application/json:
              examples:
                forbidden:
                  summary: forbidden (rate limit)
                  value:
                    code: forbidden
                    message: >-
                      Sorry, you have reached the knowledge base request rate
                      limit of your subscription.
                    status: 403
                knowledge_fs_access_denied_scope:
                  summary: knowledge_fs_access_denied (key scope)
                  value:
                    code: knowledge_fs_access_denied
                    message: Agent Knowledge Base operation is not allowed.
                    status: 403
                knowledge_fs_access_denied_upstream:
                  summary: knowledge_fs_access_denied (rejected)
                  value:
                    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
          description: >-
            - `knowledge_fs_access_denied`: the key is scoped to other knowledge
            bases, **API access** is off for this knowledge base, or the
            knowledge base is not active.

            - `knowledge_fs_access_denied`: the key has no access to this
            knowledge base's content.

            - `forbidden`: on Dify Cloud, the workspace has reached the
            knowledge base request rate limit of its subscription. Every call
            counts, reads included.
        '404':
          content:
            application/json:
              examples:
                knowledge_fs_resource_not_found:
                  summary: knowledge_fs_resource_not_found
                  value:
                    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
                not_found:
                  summary: not_found (feature off)
                  value:
                    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
          description: >-
            - `knowledge_fs_resource_not_found`: no document file has this ID,
            the key cannot read it, or no outline has been built for its current
            version.


            This `404` does not say whether indexing is still running or has
            failed. A revision's `state` says that, on [List Document
            Revisions](/en/api-reference/documents-and-chunks/list-document-revisions),
            which takes the document ID.

            - `not_found`: the Agent Knowledge Base feature is turned off on
            this deployment.
        '502':
          content:
            application/json:
              examples:
                knowledge_fs_upstream_unavailable:
                  summary: knowledge_fs_upstream_unavailable (service error)
                  value:
                    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
                knowledge_fs_upstream_unavailable_transport:
                  summary: knowledge_fs_upstream_unavailable (no response)
                  value:
                    code: knowledge_fs_upstream_unavailable
                    message: Agent Knowledge Base is unavailable.
                    status: 502
          description: >-
            - `knowledge_fs_upstream_unavailable`: no answer came back in time,
            or the answer couldn't be read. Retry after a pause.
        '503':
          content:
            application/json:
              examples:
                knowledge_fs_operation_unavailable:
                  summary: knowledge_fs_operation_unavailable
                  value:
                    code: knowledge_fs_operation_unavailable
                    message: Agent Knowledge Base operation is not available.
                    status: 503
                knowledge_fs_operation_unavailable_upstream:
                  summary: knowledge_fs_operation_unavailable (temporary)
                  value:
                    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
          description: >-
            - `knowledge_fs_operation_unavailable`: the Agent Knowledge Base
            feature is not set up for this workspace, this operation is not
            available on the deployment, or the key's access to this knowledge
            base changed while the request was being authorized.

            - `knowledge_fs_operation_unavailable`: the request can't be served
            right now. Follow `failure.retryPolicy`.
components:
  schemas:
    KnowledgeBaseOutlineHeading:
      description: >-
        Offsets refer to the parsed document text. They are not positions in the
        original file.
      properties:
        child_node_ids:
          description: IDs of the headings in `children`.
          items:
            type: string
          type: array
        children:
          description: Nested headings, in document order.
          items:
            $ref: '#/components/schemas/KnowledgeBaseOutlineHeading'
          type: array
        end_offset:
          description: >-
            Zero-based UTF-8 byte offset in the parsed document text. Exclusive
            end. `null` when unknown.
          nullable: true
          type: integer
        end_page:
          description: >-
            Last page of the section, starting at `1`. `null` when the file has
            no pages.
          nullable: true
          type: integer
        id:
          description: Heading ID.
          type: string
        level:
          description: Heading depth, starting at `1`.
          type: integer
        metadata:
          additionalProperties: true
          description: Additional heading details. Free-form object.
          type: object
        section_path:
          description: Headings from the document root to this heading, itself included.
          items:
            type: string
          type: array
        source_element_ids:
          description: IDs of the parsed elements the heading was detected from.
          items:
            type: string
          type: array
        source_node_ids:
          description: Internal. Not needed to read the outline.
          items:
            type: string
          type: array
        start_offset:
          description: >-
            Zero-based UTF-8 byte offset in the parsed document text. Inclusive
            start. `null` when unknown.
          nullable: true
          type: integer
        start_page:
          description: >-
            First page of the section, starting at `1`. `null` when the file has
            no pages.
          nullable: true
          type: integer
        summary:
          description: Generated summary of the section. `null` when none was generated.
          nullable: true
          type: string
        title:
          description: Heading text.
          type: string
        title_location:
          additionalProperties: true
          description: Where the heading sits in the file. `null` when unknown.
          nullable: true
          type: object
        toc_source:
          description: >-
            How the heading was detected: `native-toc`, `llm-inferred`,
            `parser-heading`, or `fallback`.
          type: string
      type: object
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: API_KEY
      description: >-
        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](/en/api-reference/guides/get-started)).


        Keep keys server-side; never embed them in client code. Requests with a
        missing or invalid key fail with HTTP `401` (`unauthorized`).
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.