LocalFiles

mkdir()

files.mkdir(dir) → Promise<Item>

Creates a folder, and every parent it needs. Succeeds on a folder that is already there.

freecreates parentsidempotent
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parameters

dirstringrequired

The 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

write() already creates the folders of its path

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

CodeStatusWhen
invalid_path400Absolute, outside the workspace, or the workspace root.
local_files_require_node400The runtime has no filesystem.
storage_not_on_this_machine409Another 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.