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
betaGetMcpUrl()
Beta
This feature is in beta and may change in the future.
Get the MCP URL for the sandbox.
Returns
string
MCP URL for the sandbox.
betaPause()
Beta
This feature is in beta and may change in the future.
Pause a sandbox by its ID.
Parameters
Returns
Promise<boolean>
sandbox ID that can be used to resume the sandbox.
connect()
Parameters
Returns
Promise<Sandbox>
A running sandbox instance
Example
downloadUrl()
Parameters
Returns
Promise<string>
URL for downloading file.
getHost()
Parameters
Returns
string
host address of the sandbox port.
Example
getInfo()
Parameters
Returns
Promise<SandboxInfo>
information about the sandbox
getMetrics()
Parameters
Returns
Promise<SandboxMetrics[]>
List of sandbox metrics containing CPU, memory and disk usage information.
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
Promise<string>
URL for uploading file.
betaCreate()
betaCreate(this, opts)
Beta
This feature is in beta and may change in the future.
Create a new sandbox from the default base sandbox template.
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
Constructs
SandboxbetaCreate(this, template, opts)
Beta
This feature is in beta and may change in the future.
Create a new sandbox from the specified sandbox template.
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
Constructs
SandboxbetaPause()
Parameters
Returns
Promise<boolean>
true if the sandbox got paused, false if the sandbox was already paused.
connect()
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
A running sandbox instance
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
SandboxgetFullInfo()
Parameters
Returns
Promise<object>
getInfo()
Parameters
Returns
Promise<SandboxInfo>
sandbox information.
getMetrics()
Parameters
Returns
Promise<SandboxMetrics[]>
List of sandbox metrics containing CPU, memory and disk usage information.
kill()
Parameters
Returns
Promise<boolean>
true if the sandbox was found and killed, false otherwise.
list()
Parameters
Returns
SandboxPaginator
paginator for listing sandboxes.
setTimeout()
Parameters
Returns
Promise<void>