Skip to main content
GET
/
public
/
v1
/
drive
/
tree
cURL
curl -X GET "https://api.copera.app/public/v1/drive/tree?depth=3" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "root": [
    {
      "_id": "<string>",
      "name": "<string>",
      "type": "<string>",
      "owner": "<string>",
      "createdAt": "<string>",
      "updatedAt": "<string>",
      "hasChildren": true,
      "children": [
        "<unknown>"
      ],
      "mimeType": "<string>",
      "size": 123,
      "parent": "<string>"
    }
  ],
  "totalItems": 123,
  "truncated": true,
  "nextParentIds": [
    "<string>"
  ]
}

Documentation Index

Fetch the complete documentation index at: https://developer.copera.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Retrieves the hierarchical tree structure of files and folders in the drive. Items are returned as nested nodes with their children, up to a configurable depth. This is the primary endpoint for building a file explorer or navigation sidebar.

Query Parameters

  • parentId (optional): Start the tree from this folder ID. Omit to get root-level items.
  • depth (optional): Maximum nesting depth, 1-10. Defaults to 3.

Response

Returns a tree structure with:
  • root: Array of top-level tree nodes, each with nested children
  • totalItems: Total number of items in the response
  • truncated: Whether the result was truncated (max 500 items)
  • nextParentIds: When truncated, IDs of leaf folders that have more children — use these as parentId to continue fetching
Each tree node includes:
  • id: The file or folder ID
  • name: Display name
  • type: Either file or folder
  • children: Array of nested child nodes
  • hasChildren: Boolean indicating whether this node has children beyond what was returned (useful for lazy loading)

Lazy Loading

For large drive structures, use parentId and depth together for lazy loading:
  1. Fetch the root tree with a shallow depth (e.g., depth=2)
  2. When a user expands a folder, fetch its subtree using parentId={folderId}&depth=2
  3. Use the hasChildren flag to show expand indicators in the UI

Authorizations

Authorization
string
header
required

Bearer token

Query Parameters

parentId
string

Start tree from this folder. Omit for root-level contents.

Pattern: ^[0-9a-fA-F]{24}$
depth
number

Max nesting depth (1-10). Defaults to 3.

Required range: 1 <= x <= 10

Response

Default Response

root
T1 · object[]
required
totalItems
number
required
truncated
boolean
required
nextParentIds
string[]