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

> 获取知识库的目录结构

# Get Knowledge Folder Tree



## OpenAPI

````yaml get /v1/knowledge/{knowledge_id}/folders
openapi: 3.1.0
info:
  title: spectra-server
  description: The API for Spectra Backend.
  version: 0.1.0
servers:
  - url: https://api-spectra.duplik.cn
security: []
paths:
  /v1/knowledge/{knowledge_id}/folders:
    get:
      tags:
        - Knowledge
      summary: Get Knowledge Folder Tree
      operationId: get_knowledge_folder_tree_v1_knowledge__knowledge_id__folders_get
      parameters:
        - name: knowledge_id
          in: path
          required: true
          schema:
            type: string
            title: Knowledge Id
        - name: parent_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Parent Id
            description: parent folder id
          description: parent folder id
        - name: max_level
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            description: max level, if None no limit
            title: Max Level
          description: max level, if None no limit
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FolderTreeResponse'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - HTTPBearer: []
components:
  schemas:
    FolderTreeResponse:
      properties:
        folders:
          items:
            $ref: '#/components/schemas/FolderTreeNode'
          type: array
          title: Folders
        total:
          type: integer
          title: Total
      type: object
      required:
        - folders
        - total
      title: FolderTreeResponse
    ErrorResponse:
      properties:
        code:
          type: integer
          title: Code
        message:
          type: string
          title: Message
      type: object
      required:
        - code
        - message
      title: ErrorResponse
    FolderTreeNode:
      properties:
        file_id:
          type: string
          title: File Id
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
        parent_id:
          type: string
          title: Parent Id
        parent_ids:
          items:
            type: string
          type: array
          title: Parent Ids
        children:
          items:
            $ref: '#/components/schemas/FolderTreeNode'
          type: array
          title: Children
          default: []
        has_children:
          type: boolean
          title: Has Children
          default: false
        level:
          type: integer
          title: Level
          default: 0
        permission_types:
          items:
            type: string
          type: array
          title: Permission Types
          default: []
      type: object
      required:
        - file_id
        - name
        - type
        - parent_id
        - parent_ids
      title: FolderTreeNode
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````