POST /v1/sandboxes/{sandbox_id}/files/mkdir
Creates the directory at `path` with `mode`, and any missing parents, like `mkdir -p`; each new directory is owned like the one it is made in. Answers `201` with the entry when it created the directory and `200` when a directory (or a symlink to one) was already there; a file at `path` is `409 file_exists`. Sandboxes whose template image predates this operation answer `409 guest_outdated`.

Authentication

Bearer Token (b3os_sk_ API key or b3os_pat_ token)

Path Parameters

sandbox_id string required path
The sandbox ID (`sbx_…`).
Example: "sbx_01m5t68q1b590rj801nbzsqzkk"

Request Body required

application/json
path string REQUIRED
Absolute path of the directory.
mode string
Octal mode of the directory (the umask does not apply). Parents it creates get `0755`.

Responses

200 The directory was already there.
application/json
name string REQUIRED
path string REQUIRED
type string REQUIRED
Enum: file, directory, symlink
size integer REQUIRED
mode string REQUIRED
Octal permission bits.
modified_at string (date-time) REQUIRED
target string
Symlink target.
201 The directory this request created.
400 The request failed validation (`invalid_request`, `invalid_url`).
401 Missing, malformed, expired or revoked credentials (`unauthorized`).
403 Authenticated but not allowed (`forbidden`, `egress_denied`).
404 The object does not exist or belongs to another project.
409 Something already exists at the target path (`file_exists`); also a directory that is not empty in the way (`directory_not_empty`), a sandbox that is not running (`sandbox_not_running`), or an agent that predates the operation (`guest_outdated`).
413 The request body exceeds this operation's limit.
415 The Content-Type is not accepted by this operation.
422 The path is not absolute, too long, or a parent is a file (`path_invalid`, `not_a_directory`).
429 A rate, concurrency or quota limit applies (`rate_limited`, `concurrency_limited`, `quota_exceeded`).
500 Something failed inside B3OS (`internal`). Retry with backoff.
502 The agent inside the microVM did not answer (`guest_unreachable`).
503 The node or the product is not available right now (`node_unavailable`, `product_unavailable`, `capacity_unavailable`).
curl -X POST 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/files/mkdir' \  -H 'Authorization: Bearer YOUR_API_TOKEN' \  -H 'Content-Type: application/json' \  -d '{  "path": "/workspace/data/raw"}'
const response = await fetch('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/files/mkdir', {  method: 'POST',  headers: {      "Authorization": "Bearer YOUR_API_TOKEN",      "Content-Type": "application/json"  },  body: JSON.stringify({    "path": "/workspace/data/raw"  })});const data = await response.json();console.log(data);
import requestsheaders = {    'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.post('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/files/mkdir', headers=headers, json={  "path": "/workspace/data/raw"})print(response.json())
200 Response
{  "name": "raw",  "path": "/workspace/data/raw",  "type": "directory",  "size": 4096,  "mode": "0755",  "modified_at": "2026-10-25T19:00:10.000Z"}
Ask a question... ⌘I