Migrate from E2B
onshore.sh speaks the E2B API. Your code keeps using the official e2b SDK, unmodified. You
change two environment variables.
Switch in two variables
Section titled “Switch in two variables”Create an API key
In the console at onshore.sh/app, create an API key. See API keys.
Set the variables
Terminal window export E2B_DOMAIN=onshore.shexport E2B_API_KEY=<your-ons-api-key><your-ons-api-key>is the key you just created. It starts withmsb_.Run your code
The SDK now calls
https://api.onshore.shand reaches each miniVM athttps://<port>-<sandbox-id>.onshore.sh. Code that uses thee2bSDK needs no other change.
from e2b import Sandbox
sbx = Sandbox.create(timeout=300)result = sbx.commands.run("uname -a")print(result.stdout)sbx.kill()import { Sandbox } from 'e2b'
const sbx = await Sandbox.create({ timeoutMs: 300_000 })const result = await sbx.commands.run('uname -a')console.log(result.stdout)await sbx.kill()Supported SDK versions
Section titled “Supported SDK versions”We test every release with the official SDKs:
| SDK | Package | Tested version | Runtime |
|---|---|---|---|
| Python | e2b |
2.64.0 | Python 3.11 or later |
| JavaScript | e2b |
2.64.0 | Node.js 22.19 or later |
pip install e2b==2.64.0npm install e2b@2.64.0e2b-code-interpreter is not supported yet.
What the test suite proves works: create, commands (stdout, stderr, exit codes, environment
variables, working directory), background commands, files (read, write, list, remove, watch),
PTY, ports through get_host, timeouts, metrics, list with metadata filters and paging,
pause and resume, kill, and the SDK’s error types.
What is different
Section titled “What is different”onshore.sh is safer by default. Where it differs from E2B, it does so on purpose.
Egress is closed by default
Section titled “Egress is closed by default”A miniVM reaches nothing on the internet until its template allows it. You list the domains a
template may reach in its minisandbox.yaml, by name or with presets (github, npm, pypi…).
Sandbox.create() with no template uses your organization’s base template, which reaches the
package registries only (Ubuntu, PyPI, npm, crates.io): pip install works. Any other host, such
as GitHub, is refused until you add it at create. allow_out sets the miniVM’s whole list, so
name the registries you still need too:
sbx = Sandbox.create(network={"allow_out": [ "pypi.org", "files.pythonhosted.org", "github.com", "api.github.com",]})See Network access of the base template
for ons and JavaScript, and how to see what was refused.
allow_internet_access: trueis refused with400when the template allows no egress and the create adds none.allow_internet_access: falsecloses all egress for that miniVM.network.allowOuttakes domain names (and*.domain), at create and withupdateNetwork(PUT /sandboxes/{id}/network,204). A name the template allows narrows the list. A name outside it is added, within your organization’s ceiling.network.denyOuttakes only["0.0.0.0/0"]: everythingallowOutdoes not name is closed anyway. Alone, it closes egress.- An
updateNetworkwithoutallowOutgoes back to the template’s list, andallow_internet_access: falsecloses it. - IP addresses and CIDR blocks are refused with
400: onshore.sh filters by name. So arednsServers,egressProxyandruleswhen set. - SMTP (ports 25, 465 and 587) and cloud metadata addresses are always blocked, whatever the template says.
See Egress.
Ports need the traffic token
Section titled “Ports need the traffic token”Every port of a miniVM, other than the SDK’s own, needs the e2b-traffic-access-token header.
network.allowPublicTraffic: true is refused with 400. Send the trafficAccessToken of the
create answer with your requests, or use ons forward, which adds it for you. See
Processes, files and ports.
An envdAccessToken is always issued, whatever secure says.
Pause and resume keep everything
Section titled “Pause and resume keep everything”sbx.pause() saves the miniVM’s memory and disk. Sandbox.connect(id) resumes it with its
files and running processes as they were.
- A paused miniVM costs no compute, only storage.
- Paused miniVMs are kept 30 days, then deleted.
- A timeout change on a paused miniVM answers
409: resume it first. autoPause: truepauses the miniVM instead of killing it at its timeout.- onshore.sh adds
autoPauseIdle: seconds without activity before the miniVM pauses.
See Lifecycle.
Each key sees its own miniVMs
Section titled “Each key sees its own miniVMs”Sandbox.list() and get_info return only the miniVMs created with the calling API key. Another
key of the same organization sees its own. Use one key per developer or per service.
Templates come from minisandbox.yaml
Section titled “Templates come from minisandbox.yaml”The E2B template build system (e2b template build, Template.build in the SDK) does not work
against onshore.sh. You describe a template in a minisandbox.yaml file and build it with
ons template build. Then pass its name as template to Sandbox.create, as before.
See Templates and the minisandbox.yaml reference.
The user commands run as
Section titled “The user commands run as”A miniVM runs commands and file calls as the user its template declares (user: in
minisandbox.yaml, default user; base and agents use user). Like E2B, the SDKs send no
user by default, so the call runs as that user.
On a template with user: root, or with an account of its image such as user: ubuntu, there is
no user account, so passing user="user" fails and the error names the accounts the miniVM has:
no such user "user" in this miniVM: drop the user argument to run as the template's user (root), or use one of: root, ubuntuDrop the user argument to run as the template’s user, or pass one of the accounts the error
lists. Templates built earlier also run as their template’s user without a rebuild, but their
error reads invalid username "user": no such user in the sandbox: rebuild the template
(ons template build) to get the message above. A miniVM created before this change keeps its
earlier behaviour, even after a resume: create a new one to get it.
Other differences
Section titled “Other differences”- Logs.
GET /sandboxes/{id}/logsis always empty: the platform never sees your miniVM’s output. Read it with the SDK’s commands, orons proc logs. - Metadata. Keys starting with
msb.are reserved and refused with400, except the ones onshore.sh documents (msb.ai_account,msb.github_repos,msb.label.<key>). Metadatanameandmsb.label.<key>set the miniVM’s name and labels, which every member of your organization can see: an existing metadatanamebecomes the miniVM’s name. See Name and label miniVMs. - Unsupported fields. A create field onshore.sh does not implement must be unset or at its
default. The
400message names it.networkacceptsallowOut,denyOut(above) andallowPublicTraffic: false.autoPauseMemory: falseis refused: a pause always keeps memory. - Unsupported routes. Team, node, template build and access-token management routes of the
E2B API answer
404. - Limits. A request over your organization’s limits is refused, never silently lowered. See Quotas and limits.
Extensions you may want
Section titled “Extensions you may want”Some features have no word in the E2B API. Use ons or the /v1 routes:
- Create up to 50 miniVMs at once:
POST /v1/sandboxes/batch, orons create --count. - Give a miniVM a credential it never sees: egress credentials.
- Run coding agents in miniVMs: Agent runs.