Skip to main content
Every sandbox has an independent ext4 rootfs — a copy of the base image. Writes in one sandbox never affect another. The filesystem API lets you read and write files, list directories, watch for changes, and upload or download data.

Write a file

Write multiple files at once

write_files() uploads multiple files in a single request.

Binary files

sbx.files.write() accepts both strings and raw bytes. When you pass bytes / Uint8Array, the SDK routes the payload to the binary-safe PUT /files/raw endpoint automatically (500 MiB cap) — PNGs, compiled artifacts, and base64-decoded payloads round-trip byte-identically without any manual encoding.
For uploads larger than 500 MiB, use the streaming upload_url() / download_url() helpers. See the Binary File Operations cookbook for a full walkthrough including batch writes with mixed str + bytes entries.

WriteEntry model

WriteInfo model

write() returns a WriteInfo with metadata about the written file.

Read a file

List a directory

EntryInfo model

Check if a path exists

Get file info

Create a directory

Rename or move a file

Remove a file or directory

Watch a directory for changes

watch_dir() / watchDir() registers a watcher on the directory and returns a WatchHandle. The handle buffers FilesystemEvent objects internally — drain them with get_new_events() / getNewEvents(), and call stop() when you’re done.
Full SSE streaming into the WatchHandle buffer is still landing. The current release registers the watcher server-side and exposes the poll API; events may not populate until the streaming change ships.

FilesystemEvent model

Upload and download patterns

Upload a local file to the sandbox

Download a file from the sandbox

Upload multiple files efficiently

The write_files() batch call is more efficient than calling write() in a loop. It sends all files in a single HTTP request.

Streaming upload and download

sbx.files.read() and sbx.files.write() buffer the whole payload in memory, which is fine up to ~10 MiB. For larger files — model weights, datasets, snapshot archives — use the raw streaming endpoints. sbx.upload_url() and sbx.download_url() return path-based URLs under api.declaw.ai that accept binary bodies up to 500 MiB, streamed end-to-end. Requests must include your X-API-Key header. The URLs are safe to use from your own processes (CI jobs, local scripts, agents), but should not be shared to third parties because the API key is still required separately.
Example binary upload with curl:
Example download: