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
Responses
Section titled “ Responses ”Successful Response
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 childrentotal_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
Root folder nodes
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 metadatachildren: 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 metadata
object
Unique folder identifier
Folder display name
Folder color (hex)
Folder icon name
Folder description
Creation timestamp (ISO 8601)
Last update timestamp (ISO 8601)
Sort order position
Documents in folder
Document IDs in folder
Total folder count