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
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()
Call Signature
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
SandboxCall Signature
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.
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
A running sandbox instance
Example
create()
Call Signature
base sandbox template.
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
Constructs
SandboxCall Signature
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
Constructs
SandboxgetFullInfo()
Parameters
Returns
Promise<{
cpuCount: number;
endAt: Date;
envdAccessToken: undefined | string;
envdVersion: string;
memoryMB: number;
metadata: {};
name: string;
sandboxDomain: undefined | string;
sandboxId: string;
startedAt: Date;
state: "running" | "paused";
templateId: string;
}>
Parameters
Returns
Promise<SandboxInfo>
sandbox information.
Parameters
Returns
Promise<SandboxMetrics[]>
List of sandbox metrics containing CPU, memory and disk usage information.
Parameters
Returns
Promise<boolean>
true if the sandbox was found and killed, false otherwise.
Parameters
Returns
SandboxPaginator
paginator for listing sandboxes.
setTimeout()
Parameters
Returns
Promise<void>