Get all folders
Knowledge Base
Get all folders
Retrieve all knowledge base folders for your organization.
GET
Get all folders
Overview
Retrieve all knowledge base folders for your organization. Folders help organize documents used by your AI assistants, making it easy to manage and structure your knowledge base. This endpoint returns a hierarchical structure of folders with their associated documents and subfolders.Use Cases
- Folder Selection: Display available folders when uploading documents
- Knowledge Base Browser: Build a file explorer interface
- Organization Overview: See how your knowledge base is structured
- Document Count: Understand content distribution across folders
- Assistant Configuration: Show folders linked to specific assistants
Authentication
This endpoint requires authentication using an API key. Include your API key in the request header:Response Structure
Returns an array of folder objects with hierarchical structure:Folder Object
Document Object (Simplified)
Example Request
Example Response
Common Use Cases
1. Display Folder Tree
2. Find Folder by Name
3. Build Folder Dropdown
4. Count Total Documents
Hierarchical Structure
Folders are organized hierarchically:- Root Folders: Have
parent_folder_id: null - Subfolders: Have
parent_folder_idpointing to parent - Nesting: Unlimited depth of nested folders
- Documents: Each folder has
documentsarray
Error Responses
Important Notes
- Hierarchical: Response includes full folder tree with nesting
- Document Summary: Only includes document id, name, and icon (not full content)
- Alphabetical: Folders typically sorted alphabetically
- No Pagination: Returns all folders in one request
- Empty Folders: Folders with no documents still appear
Related Endpoints
- POST /api/documents/assistant/folders - Create a new folder
- POST /api/documents/assistant/raw - Upload document to folder
- DELETE /api/documents/assistant/ - Delete a document
Performance Tips
- Cache Response: Folder structure changes infrequently
- Client-side Filtering: Filter and search folders on client side
- Lazy Loading: For large folder trees, consider lazy loading subfolders
Headers
API key needed to authorize the request
