Before you begin
- A document to file. Any document works; the examples use an employment agreement.
Two folder trees
Every folder belongs to one of two trees, and thescope of a folder says which:
A folder belongs to its tree for its whole life; there is no way to hand one tree’s folder to the other. A document is different: it holds one placement per tree, so the same document can sit in a folder of your personal tree and, at the same time, somewhere in the shared tree. A placement is a pair — the
scope and the folderId inside it, where null means the root of that tree.
Step 1: Create a folder
A folder needs a name;scope says which tree it goes into — personal unless you say otherwise:
Request
Response
parentFolderId is null, so this folder sits at the root of the personal tree. Pass one to create a folder inside another. Keep the id — filing a document means naming that folder.
Step 2: File the document into it
A document is placed one tree at a time, and the tree is part of the path:Request
Response
folderId: null places the document at the root of the tree.
Step 3: Put the document in the shared tree as well
Placing it in the other tree leaves the first placement alone:Request
Response
In the shared tree a document also takes on the access rights of the folder it lands in, so filing it there can widen who is able to see it. Moving it away afterwards does not narrow those rights again.
Step 4: Read where the document sits
The document itself reports its placements:Request
Response
DELETE /documents/{id}/folders/shared removes the shared entry and leaves the personal one untouched. Removing the last one leaves folders empty; the document is then unfiled, which is a perfectly normal state — it is still readable, searchable and signable, it just sits in no folder.
Step 5: Find your folders again
Folders are their own collection, with their own search:Request
Response
GET /documents?folderId=… returns the documents placed directly in a folder — and with recursive=true everything nested deeper. Walking a tree therefore means asking twice per level, once for each collection.
Narrow the folder search the same way: scope for a whole tree, parentFolderId for the folders directly inside one, recursive to reach any depth, and name to look one up by what it is called. A folder itself is moved with PUT /folders/{id}/parent, naming the new parent, or null for the root of its tree.
DELETE /folders/{id} takes the folder’s whole subtree with it — the folders inside it and their documents all go to the trash together, or are removed for good when you pass permanent. Two exceptions: on a move to the trash, documents in your personal tree that you can only read are just removed from the folder; and if the subtree holds a document you cannot delete — in the shared tree, or a read-only one on a permanent delete — nothing is deleted and the call answers 409.POST /folders/{id}/restore takes it out of the trash together with everything that went in with it. When you already hold a folder’s identifier, GET /folders/{id} reads that one folder without a search.
Complete example
Filing a document into a new folder, as a Node.js script. Error handling is minimal for brevity — in production, inspect the error envelope of non-2xx responses.Next steps
- Search inside a folder, or across both trees — Search documents.
- Bring back a document deleted by mistake, or remove one for good — Delete and restore a document.