Write a file
- Python
- TypeScript
Write multiple files at once
write_files() uploads multiple files in a single request.
- Python
- TypeScript
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.
- Python
- TypeScript
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
- Python
- TypeScript
List a directory
- Python
- TypeScript
EntryInfo model
Check if a path exists
- Python
- TypeScript
Get file info
- Python
- TypeScript
Create a directory
- Python
- TypeScript
Rename or move a file
- Python
- TypeScript
Remove a file or directory
- Python
- TypeScript
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.
- Python
- TypeScript
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.