Skip to main content
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_id pointing to parent
  • Nesting: Unlimited depth of nested folders
  • Documents: Each folder has documents array

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

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

x-api-key
string
required

API key needed to authorize the request

Response

Folders retrieved successfully.

id
string
Example:

"550e8400-e29b-41d4-a716-446655440000"

name
string
Example:

"Product Documentation"

icon
string
Example:

"📚"

sort_order
number
Example:

0

created_at
string
Example:

"2024-01-15T10:00:00.000Z"

documents
object[]
subfolders
object[]