E2B_API_KEY and E2B_API_URL=https://api.styne.ai set (Switch from E2B).
Move files in and out
Four ways, from the smallest file to a whole folder. Pick by size and by who is moving the data.Small files with the SDK
files.write creates missing folders. Read binary files with format="bytes" (Python) or { format: 'bytes' } (TypeScript).
Any size with a signed URL
The API makes a link that carries its own signature, valid for one sandbox, one path and one direction until it expires. Upload or download with plaincurl, with no key and no SDK, streamed with no size cap besides the sandbox’s disk.
{"url", "method", "operation", "path", "expiresAt"}. Fetch url with method:
A whole folder with tar
tar -czf project.tgz project), write it with
files.write, and extract it in the sandbox the way the last two lines do.
Find and change files in place
Reading, writing, listing, moving and removing files works through the E2B SDKs. The routes below add what a coding agent also needs: find files by name, find text in files, replace text across files, change permissions, and hand a short-lived link to someone who has no API key. They are on the native API; the E2B SDKs do not have them. Every route isPOST /sandboxes/{id}/files/... with the account’s API key, and answers JSON. Paths are absolute; a relative path starts in
/root, where a command starts when it names no cwd.
Every value you send reaches the sandbox as an argument, never as shell text, so a path or pattern with quotes, $(...)
or ; in it is only data. Results are cut at a limit (default 1000, at most 10000; a limit outside 1 to 10000 is cut to that range) and say "truncated": true when there
was more.
Search by name
pattern is a glob on the file name; a pattern with a / in it is matched against the whole path. type is file,
directory or any (default). depth is 1 to 64. The answer is {"files": ["/home/user/project/src/a.rs", ...], "truncated": false}. /proc, /sys and /dev are never searched and symbolic links are not followed.
Find text
query is a literal string; with "regex": true it is an extended regular expression (an invalid one is a 400).
glob limits the search to file names that match (a name pattern, no /). Binary files are skipped and so are files
over maxFileKiB (default 1024, at most 8192). The answer is {"matches": [{"path", "line", "text"}], "truncated"};
a matching line is cut at 512 bytes.
Replace text
old by new. Name the files either with files (a list of at most
1000 paths) or with path and glob, which takes every text file under path that contains old. dryRun counts
without writing. The answer lists each changed file with its count: {"files": [{"path", "replacements"}], "replacements": 12, "truncated": false, "dryRun": true}. A file that is not UTF-8 text or is over 8 MiB is listed with
an error and left alone. Each file is read and written back in place, so its mode and owner stay; there is no lock, so
a file the sandbox changes during the call is overwritten with the version this call read.
Permissions
mode is 3 or 4 octal digits; owner and group are a user or group name, or a numeric id. Give at least one of the
three. The answer is the entry as it is afterwards: {"entry": {"path", "mode", "permissions", "owner", "group", ...}}.
Signed upload and download URLs
operation is upload or download; expiresIn is 1 to 86400 seconds (default 300). The answer is
{"url", "method", "operation", "path", "expiresAt"}. The URL carries its own signature and needs no API key and no
access token:
signature the E2B SDKs compute locally from the access token is not
checked here, and the SDKs’ own calls keep using X-Access-Token.
Things to know
- Files are on the sandbox’s disk (1 GiB on
base). They stay across a pause and go when the sandbox is killed: take what you need out first. - After a kill, a snapshot is the only copy of the disk; run
syncbefore you save it so every file is on it. - On the routes of the native API a relative path starts in
/root, the folder a command starts in. The E2B SDKs resolve relative paths in/home/user, as E2B does.