Skip to main content
sbx.files is the Filesystem instance available on every Sandbox. All paths must be absolute paths within the sandbox filesystem.

sbx.files.read()

Read a file’s content as a string.
string
required
Absolute path inside the sandbox.
string
default:"'user'"
Unix user context for the read operation.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<string>

sbx.files.write()

Write content to a file, creating parent directories automatically.
string
required
Absolute destination path.
string | Uint8Array
required
Content to write. Accepts a string or a Uint8Array (decoded as UTF-8).
string
default:"'user'"
Unix user context.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<WriteInfo>

sbx.files.writeFiles()

Write multiple files in a single batch request.
WriteEntry[]
required
Array of WriteEntry objects. Each has path (string) and data (string or Uint8Array).
string
default:"'user'"
Unix user context applied to all files.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<WriteInfo[]>

sbx.files.list()

List entries in a directory.
string
required
Absolute path to the directory.
number
default:"1"
Recursion depth. 1 lists only immediate children.
string
default:"'user'"
Unix user context.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<EntryInfo[]>

sbx.files.exists()

Check whether a path exists.
string
required
Absolute path to check.
string
default:"'user'"
Unix user context.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<boolean>

sbx.files.getInfo()

Get metadata about a file or directory.
string
required
Absolute path to query.
string
default:"'user'"
Unix user context.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<EntryInfo>

sbx.files.remove()

Remove a file or directory.
string
required
Absolute path to remove.
string
default:"'user'"
Unix user context.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<void>

sbx.files.rename()

Rename or move a file or directory.
string
required
Current absolute path.
string
required
New absolute path. Can be in a different directory (move semantics).
string
default:"'user'"
Unix user context.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<EntryInfo> for the renamed entry.

sbx.files.makeDir()

Create a directory (including parent directories if needed).
string
required
Absolute path of the directory to create.
string
default:"'user'"
Unix user context.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<boolean>true if the directory was created.

sbx.files.watchDir()

Watch a directory for filesystem change events.
string
required
Absolute path of the directory to watch.
string
default:"'user'"
Unix user context.
boolean
default:"false"
Whether to watch subdirectories recursively.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<WatchHandle>

Data models

EntryInfo

FileType

WriteInfo

WriteEntry

FilesystemEvent

FilesystemEventType

WatchHandle

The handle uses a poll-and-drain model — call getNewEvents() to pull buffered events. There is no async iterator or callback subscription.

Examples

Upload and run a script

Batch upload a dataset

Download generated output

Check and create directories