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 writeshello, 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.
ls | head -n 1000.
Recover from a Failed Write
A failedwrite 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:
- Read a file and Write a file
- List a directory and Create a directory
- Check whether a path exists and Remove a path
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.