Sandbox
E2B cloud sandbox is a secure and isolated cloud environment. The sandbox allows you to:- Access Linux OS
- Create, list, and delete files and directories
- Run commands
- Run isolated code
- Access the internet
Example
Properties
Methods
downloadUrl()
Parameters
Returns
string
URL for downloading file.
getHost()
Parameters
Returns
string
host address of the sandbox port.
Example
isRunning()
Parameters
Returns
Promise<boolean>
true if the sandbox is running, false otherwise.
Example
kill()
Parameters
Returns
Promise<void>
setTimeout()
.setTimeout.
Maximum time a sandbox can be kept alive is 24 hours (86_400_000 milliseconds) for Pro users and 1 hour (3_600_000 milliseconds) for Hobby users.
Parameters
Returns
Promise<void>
uploadUrl()
Parameters
Returns
string
URL for uploading file.
connect()
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the existing sandbox.
Example
create()
create(this, opts)
base sandbox template.
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
Constructs
Sandboxcreate(this, template, opts)
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
Constructs
Sandboxkill()
Parameters
Returns
Promise<boolean>
true if the sandbox was found and killed, false otherwise.
list()
Parameters
Returns
Promise<SandboxInfo[]>
list of running sandboxes.
setTimeout()
Parameters
Returns
Promise<void>
Interfaces
SandboxOpts
Options for creating a new Sandbox.Properties
accessToken?
Default
apiKey?
Default
debug?
Internal
If true the SDK starts in the debug mode and connects to the local envd API server.
Default
E2B_DEBUG // environment variable orfalse
domain?
Default
E2B_DOMAIN // environment variable ore2b.dev
envs?
envs argument when executing commands or code.
Default
logger?
Logger interface—for example, console.