Skip to content

Get Folder Tree

GET
/api/writing/folders/tree

🌳 Get folder tree.

Retrieves the complete folder hierarchy as a nested tree structure.

Args: service: Injected DocumentCategoriesService instance

Returns: WritingFolderTreeResponse: Nested tree structure with all folders and children

Raises: HTTPException 500: If folder tree retrieval fails

Successful Response

WritingFolderTreeResponse

Response model for folder tree operations in Writing Studio.

Provides complete hierarchical folder structure for tree-based folder navigation and organization. Includes nested children at all levels.

Fields:

  • tree: List of root-level WritingFolderTreeNode objects with nested children
  • total_folders: Total number of folders in the tree

Usage: GET /api/creative/categories/folders/tree returns this model.

JSON Example:

{
  "tree": [
    {
      "folder": {"id": "folder_1", "name": "Drafts", ...},
      "children": [...],
      "documents": ["doc_1", "doc_2"]
    }
  ],
  "totalFolders": 5
}
object
tree
required
Tree

Root folder nodes

Array<object>
WritingFolderTreeNode

Folder tree node with nested children for hierarchical display.

Represents a single node in the folder hierarchy including the folder data, child nodes, and document IDs within the folder. Supports unlimited nesting for complex folder structures.

Fields:

  • folder: WritingFolderResponse with folder metadata
  • children: List of child WritingFolderTreeNode objects (recursive)
  • documents: List of document IDs contained in this folder

Usage: Used within WritingFolderTreeResponse for nested tree structures.

JSON Example:

{
  "folder": {"id": "folder_1", "name": "Chapters", ...},
  "children": [
    {"folder": {"id": "folder_2", "name": "Chapter 1", ...}, "children": [], "documents": ["doc_1"]}
  ],
  "documents": []
}
object
folder
required
WritingFolderResponse

Folder metadata

object
id
required
Id

Unique folder identifier

string
name
required
Name

Folder display name

string
>= 1 characters <= 100 characters
parentId
Any of:
string
color
Color

Folder color (hex)

string
default: #6366f1
icon
Icon

Folder icon name

string
default: folder
description
Description

Folder description

string
""
createdAt
required
Createdat

Creation timestamp (ISO 8601)

string
updatedAt
required
Updatedat

Last update timestamp (ISO 8601)

string
order
Order

Sort order position

integer
0
documentCount
Documentcount

Documents in folder

integer
0
children
Array<object> recursive
documents
Documents

Document IDs in folder

Array<string>
totalFolders
required
Totalfolders

Total folder count

integer