sbx.files is the Filesystem sub-module available on every Sandbox instance. All paths must be absolute paths within the sandbox filesystem.
sbx.files.read()
Read a file’s content from the sandbox.
Absolute path inside the sandbox.
Output format. One of
"text" (returns str), "bytes" (returns
bytearray), or "stream" (returns Iterator[bytes]).Unix user context for the read operation.
Per-request HTTP timeout in seconds.
str | bytearray | Iterator[bytes]
sbx.files.write()
Write content to a file. Creates parent directories automatically.
Absolute path inside the sandbox. Parent directories are created if they do
not exist.
Content to write. Accepts a string, bytes object, or any file-like object
with a
read() method.Unix user context.
Per-request HTTP timeout in seconds.
WriteInfo
sbx.files.write_files()
Write multiple files in a single batch request. More efficient than calling
write() in a loop.
List of
WriteEntry objects. Each has path (str) and data (str or
bytes).Unix user context applied to all files.
Per-request HTTP timeout in seconds.
list[WriteInfo]
sbx.files.list()
List the contents of a directory.
Absolute path to the directory.
Recursion depth.
1 lists only the immediate children of the directory.
None or a larger value recurses deeper.Unix user context.
Per-request HTTP timeout in seconds.
list[EntryInfo]
sbx.files.exists()
Check whether a file or directory exists.
Absolute path to check.
Unix user context.
Per-request HTTP timeout in seconds.
bool
sbx.files.get_info()
Get metadata about a single file or directory entry.
Absolute path to query.
Unix user context.
Per-request HTTP timeout in seconds.
EntryInfo
sbx.files.remove()
Remove a file or directory.
Absolute path to remove.
Unix user context.
Per-request HTTP timeout in seconds.
None
sbx.files.rename()
Rename or move a file or directory.
Current absolute path.
New absolute path. Can be a different directory (move semantics).
Unix user context.
Per-request HTTP timeout in seconds.
EntryInfo for the renamed entry.
sbx.files.make_dir()
Create a directory (including parent directories if needed).
Absolute path of the directory to create.
Unix user context.
Per-request HTTP timeout in seconds.
bool — True if the directory was created.
sbx.files.watch_dir()
Watch a directory for filesystem events. Returns a WatchHandle that receives
events from the sandbox.
Absolute path of the directory to watch.
Unix user context.
Per-request HTTP timeout in seconds.
Watch the directory and all subdirectories recursively.
WatchHandle
Data models
EntryInfo
FileType
WriteInfo
WriteEntry
FilesystemEvent
FilesystemEventType
WatchHandle
get_new_events() to pull
buffered events. There is no iterator protocol or callback subscription.