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 git operations
- Run isolated code
- Access the internet
Example
Properties
Methods
betaPause()
Parameters
Returns
Promise<boolean>
Deprecated
Use Sandbox.pause instead.connect()
Parameters
Returns
Promise<Sandbox>
A running sandbox instance
Example
createSnapshot()
snapshotId with Sandbox.create(snapshotId) to create a new sandbox from the snapshot.
Parameters
Returns
Promise<SnapshotInfo>
snapshot information including the snapshot ID.
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
getMcpToken()
Returns
Promise<undefined | string>
MCP token for the sandbox, or undefined if MCP is not enabled.
getMcpUrl()
Returns
string
MCP URL for 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<boolean>
true if the sandbox was killed, false if the sandbox was not found.
listSnapshots()
Parameters
Returns
SnapshotPaginator
paginator for listing snapshots from this sandbox.
pause()
Parameters
Returns
Promise<boolean>
true if the sandbox got paused, false if the sandbox was already paused.
Example
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>
updateNetwork()
Parameters
Returns
Promise<void>
uploadUrl()
Parameters
Returns
Promise<string>
URL for uploading file.
betaPause()
Parameters
Returns
Promise<boolean>
Deprecated
Use SandboxApi.pause instead.connect()
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
SandboxcreateSnapshot()
Parameters
Returns
Promise<SnapshotInfo>
snapshot information including the snapshot name that can be used with Sandbox.create().
deleteSnapshot()
Parameters
Returns
Promise<boolean>
true if the snapshot was deleted, false if it was not found.
getFullInfo()
Parameters
Returns
Promise<SandboxInfo>
sandbox information.
Deprecated
Use Sandbox.getInfo instead.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()
query.state set in opts), returns sandboxes in both
running and paused states. To filter by state, pass
opts.query.state = [...].
Parameters
Returns
SandboxPaginator
a SandboxPaginator that yields pages of sandboxes
(running and paused by default). Iterate pages via
await paginator.nextItems() while paginator.hasNext is true.
listSnapshots()
Parameters
Returns
SnapshotPaginator
paginator for listing snapshots.
pause()
Parameters
Returns
Promise<boolean>
true if the sandbox got paused, false if the sandbox was already paused.
setTimeout()
Parameters
Returns
Promise<void>
updateNetwork()
Parameters
Returns
Promise<void>