PUT /v1/sandboxes/{sandbox_id}/files
Writes the request body to `path`, replacing any existing file, creating parent directories with `mkdir=1`. Returns the file's entry. Up to 64 MiB per request.

Authentication

Bearer Token (b3os_sk_ API key or b3os_pat_ token) API Key (cookie: __Host-b3os_session)

Path Parameters

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

Query Parameters

path string required query
Absolute path inside the sandbox.
Example: "/workspace/main.py"
mode string optional query
Octal file mode for a new file.
mkdir integer optional query
`1` creates missing parent directories.

Request Body required

application/octet-stream
string (binary)

Responses

200 The written file.
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.
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 No such sandbox in this project (`sandbox_not_found`).
409 The sandbox is paused or stopped (`sandbox_not_running`).
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 PUT 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/files?path=%2Fworkspace%2Fmain.py' \  -H 'Authorization: Bearer YOUR_API_TOKEN' \  -H 'Content-Type: application/json' \  -d '"string"'
const response = await fetch('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/files?path=%2Fworkspace%2Fmain.py', {  method: 'PUT',  headers: {      "Authorization": "Bearer YOUR_API_TOKEN",      "Content-Type": "application/json"  },  body: JSON.stringify("string")});const data = await response.json();console.log(data);
import requestsheaders = {    'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.put('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/files?path=%2Fworkspace%2Fmain.py', headers=headers, json="string")print(response.json())
200 Response
{  "name": "main.py",  "path": "/workspace/main.py",  "type": "file",  "size": 812,  "mode": "0644",  "modified_at": "2026-10-25T19:01:30.000Z"}
Ask a question... ⌘I