# Get all directories (folders)
Source: https://docs.file.ai/api-reference/folders/get-all-directories-folders

> Retrieve all directories (folders) in the workspace with hierarchical structure.

get /prod/v1/directories

Retrieve all directories (folders) in the workspace with hierarchical structure.

This endpoint returns a paginated list of directories including their nested subfolders. Each directory includes breadcrumb navigation for easy hierarchy tracking.

Pagination is over TOP-LEVEL directories: one page row is one root folder, returned with its complete subtree. A subfolder is therefore never a page row of its own — reach it through its root's `subfolders`, or use cursor mode for a flat walk of every directory. Because a page carries whole subtrees, page size in bytes is driven by how deep those trees are; prefer cursor mode for large workspaces.

Query Parameters:

- page (optional): Page number for pagination (default: 1)

- limit (optional): Number of TOP-LEVEL directories per page (default: 100). Subfolders nested under a returned root do not count against it, so this bounds rows, NOT total directories returned — a page whose subtrees expand past 5000 directories is rejected with 400; lower `limit` or use cursor mode.

- search (optional): Case-insensitive substring match on the directory name. When present, `directories` is a FLAT list of matches — no `subfolders` nesting — and each match carries its full `breadcrumbs` path. Omit it to get the nested tree.

Response:

The response includes:
- directories: Array of directory objects with nested subfolders

- count: Total number of TOP-LEVEL directories, i.e. the number of page rows across all pages. Divide by `limit` for the page count.

- currentPage: Current page number

Each directory object contains:
- Basic information: id, name, description, status

- Hierarchy information: parentId, depth, breadcrumbs, subfolders

- Metadata: userId, organizationId, workspaceId

- Timestamps: createdAt, updatedAt

- isFromAutomatedRule: Indicates if directory was created by automation

Notes:

- Directories are returned with their complete subfolder hierarchy

- Breadcrumbs provide the full path from root to current directory

- Subfolders array contains nested directories recursively

Cursor pagination: pass the `cursor` query parameter (empty for the first page) and the response becomes `{ data, pagination: { limit, nextCursor, hasMore } }` where `data` is a FLAT list of directories — no `subfolders` nesting; each row carries its `breadcrumbs` ancestor path instead. Follow `nextCursor` until `hasMore` is false. Cursors are bound to the `search` value they were minted with; keep it identical for every page of a walk.
