Parameters
dirstringrequiredThe folder to create, relative to the workspace. The workspace root is refused.
await pc.files.mkdir("Clients/Acme/2026");
// { name: "2026", path: "Clients/Acme/2026", type: "folder", size: null, mimeType: null, modifiedAt: "…" }
// Calling it again changes nothing and still answers
await pc.files.mkdir("Clients/Acme/2026");pc.files.mkdir("Clients/Acme/2026")
# {"path": "Clients/Acme/2026"}
# Calling it again changes nothing and still answers
pc.files.mkdir("Clients/Acme/2026")Parents are created too
Clients and Clients/Acme are created if they are not there. So a tree is one call, not one call per level — and an existing folder along the way is left exactly as it is.
You rarely need it
mkdir() is for an empty folder you want to exist on its own — a destination prepared in advance, a structure shown in an interface. For writing a file, go straight to write().
Errors
| Code | Status | When |
|---|---|---|
| invalid_path | 400 | Absolute, outside the workspace, or the workspace root. |
| local_files_require_node | 400 | The runtime has no filesystem. |
| storage_not_on_this_machine | 409 | Another computer's storage. |
A path that names an existing file is a filesystem error, not one of ours: the operating system refuses to make a folder where a file sits, and the message comes through.