Skip to main content
A sandbox has its own disk. You write input into it, run a command, and read the output back before the sandbox ends. Files you need after that belong in a Volume. Before You Begin: BOXROUTER_API_KEY set and a client installed, as in the quickstart.

Pick a Call by Size

Each sandbox read or write call holds the whole file in memory up to limits.file_transfer_bytes. A larger read fails with 413 output_limit, and a larger write fails with 413 resource_limit. Use a Volume for larger files.

Write, Run, Read

This writes hello, upper-cases it with a command in the sandbox, and reads the result. Bytes go in and come out exactly: the SDKs use bytes in Python and Uint8Array in TypeScript, and decode only text. The HTTP example uses curl and jq. Each example requests sandbox cleanup. Recover from Errors covers a deletion that stays pending.
write creates any missing parent directories, and the file is readable and writable by the user that commands run as. It promises nothing more: BoxRouter sets no specific owner or permissions, adds no executable bit, and does not make replacing a file atomic. Reading a path that doesn’t exist fails with 404 not_found and outcome: not_started.

Store Large Files

Use a Volume for a file that exceeds the inline limit or needs to outlive a sandbox. Upload the file to the Volume, then attach it to the sandbox that uses it.

Manage Directories

list reads the immediate entries of a directory without recursing or following links. The API describes entries sorted by name, each with a type of file, directory, symlink or other. exists checks a path. remove needs recursive for a directory that has contents; without it the call fails with invalid_state. Each example creates and then requests deletion of a sandbox.
A directory with more entries than the route allows fails to list; it is never cut short. List part of it from a command, such as ls | head -n 1000.

Recover from a Failed Write

A failed write or remove can leave partial changes. If the error’s outcome is unknown, read the operation before you retry. Send an idempotency key with the original request, and reuse it for the same request if a retry is safe. Each operation’s guarantees are in the reference:

Next Steps

Keep Files across Sandboxes

Keep files after the sandbox is destroyed.

Run a Background Process

Produce output with a long-running command.

Recover from Errors

Recover from a failed write.