Sandbox object, and the Python SDK uses a Client.
Read the gaps first if your code uses run_code results, file
watching, or sandboxes that delete themselves after a timeout.
What maps to what
Move your code
1
2
Create the machine
E2B creates a sandbox that lives for its timeout. An InstaBox machine lives until you delete it, and
pauses after idle minutes on its own. The default template,
create waits until the machine runs.agent-browser, has Linux, Python 3, Node.js, a desktop and a browser. To
start from your own image, see Use your E2B template.3
Run commands and code
exec returns a non-zero exit code in r.exit_code. In TypeScript, commands.run
throws on it, as E2B does. A command stops after timeout seconds (60 by default, 600 at most).4
Move files
/data/home where your E2B code used /home/user. Files under /data
survive a stop.5
Give a port a URL
E2B’s Ports 1024 to 65535 can be published, up to 16 per machine. For a URL only people with a link can
open, publish it private:
get_host(port) returns a host name. On InstaBox, publish the port once. The result has the
URL, https://<port>-<machine id without m_>.<domain>. A port is public by default, as on E2B.sbx.ports.publish(8000, { access: 'private' }) in TypeScript, or
"access": "private" in the Python request. A private port’s plain url answers 401. Share
the response’s tokenUrl instead, the URL with the token as ?_token=. Only the publish that
creates or rotates the token returns tokenUrl, so keep it, or publish again with
rotateToken: true for a new one. See Public and private ports.6
Pause, resume and delete
Use your E2B template
An E2B template is built from a Dockerfile. Build the same Dockerfile with Docker, push it to a registry, and import it as a snapshot. The import needs a key withimages:write, and creating from
the snapshot by name needs images:read, as well as the machine scopes from the first step.
Sandbox.create takes the snapshot name and looks it up.
linux/amd64 images work. The image’s ENV reaches every command, and its CMD runs as a
service. See Custom images.
What has no direct equivalent
Migrate with your coding agent
Paste this prompt into your coding agent in the repository that uses E2B:Migration prompt
Troubleshooting
401 missing_api_key
401 missing_api_key
INSTABOX_API_KEY is not set in the process that runs the code. E2B’s E2B_API_KEY is not read.429 rate_limited: sandbox start limit reached
429 rate_limited: sandbox start limit reached
Each workspace may start only a set number of machines a minute; the free plan allows the fewest.
A create counts, and so does a resume, including
Sandbox.connect and ensure_running on a paused
machine. Code that created many short-lived E2B sandboxes in a loop hits this first. Retry only when
the error’s code is rate_limited: wait a minute and retry, or reuse one machine across jobs
instead of creating one per job. Another 429, such as quota_exceeded, does not clear by
waiting, so do not retry it. See Limits.403 missing_scope
403 missing_scope
The key lacks a scope the call needs.
snapshot import needs images:write, and creating from a
snapshot by name (or client.snapshots.list()) needs images:read. Create a key with those scopes
added, or with Full access. See API keys.400 bad_request: unknown template, when creating from your imported image
400 bad_request: unknown template, when creating from your imported image
An imported image is a snapshot, not a template. In Python pass
snapshot_id=snap.id, not
template=. See Use your E2B template.403 template_not_allowed
403 template_not_allowed
The free plan creates only from some templates. A machine from your own imported snapshot is not
limited. See Pricing.
The port URL answers 502 or 503
The port URL answers 502 or 503
502: nothing listens on the port yet, or the server listens on 127.0.0.1 only. Listen on
0.0.0.0. 503: the machine is paused or stopped. A visit wakes a machine that paused itself.A command fails with No such file or directory under /home/user
A command fails with No such file or directory under /home/user
The home directory is
/data/home. Change the path, or use paths relative to HOME in commands.SDK quick start
Every TypeScript call, with curl.
Python SDK
Every Python call and error.