Sandbox
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.
Throws
SandboxError withstatusCode 400 when mode: 'filesystem'
is requested but the feature is not enabled for the team
(snapshot_filesystem_only_disabled), and with statusCode 409 when the
sandbox’s node runs an orchestrator that predates the option
(snapshot_filesystem_only_unsupported_node). A full memory snapshot
still works in both cases; for 409, pause and resume the sandbox and retry.
Example
doubleClick()
Parameters
Returns
Promise<void>
downloadUrl()
Parameters
Returns
Promise<string>
URL for downloading file.
drag()
Parameters
Returns
Promise<void>
fork()
count new sandboxes are created from that snapshot. All forks boot from
the same snapshot, so the snapshot is captured once regardless of count.
Each fork succeeds or fails independently — the returned array contains
one entry per requested fork, either a running Sandbox instance or
an Error describing why that fork failed to start
(Promise.allSettled-style). Per-fork error codes map to the same error
classes as other API errors (e.g. 429 to RateLimitError).
Parameters
Returns
Promise<(Sandbox | Error)[]>
array with one entry per requested fork — a sandbox instance or an error.
Example
getApplicationWindows()
Parameters
Returns
Promise<string[]>
The ID of the window.
getCurrentWindowId()
Returns
Promise<string>
The ID of the current window.
getCursorPosition()
Returns
Promise<CursorPosition>
A object with the x and y coordinates
Throws
Error if cursor position cannot be determinedgetHost()
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.
getScreenSize()
Returns
Promise<ScreenSize>
An ScreenSize object
Throws
Error if screen size cannot be determinedgetWindowTitle()
Parameters
Returns
Promise<string>
The title of the window.
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.
launch()
Parameters
Returns
Promise<void>
leftClick()
Parameters
Returns
Promise<void>
listSnapshots()
Parameters
Returns
SnapshotPaginator
paginator for listing snapshots from this sandbox.
middleClick()
Parameters
Returns
Promise<void>
mousePress()
Parameters
Returns
Promise<void>
mouseRelease()
Parameters
Returns
Promise<void>
moveMouse()
Parameters
Returns
Promise<void>
open()
Parameters
Returns
Promise<void>
pause()
Parameters
Returns
Promise<boolean>
true if the sandbox got paused, false if the sandbox was already paused.
Example
press()
Parameters
Returns
Promise<void>
rightClick()
Parameters
Returns
Promise<void>
screenshot()
Call Signature
Returns
Promise<Uint8Array<ArrayBufferLike>>
A Uint8Array bytes representation of the screenshot.
Call Signature
Parameters
Returns
Promise<Uint8Array<ArrayBufferLike>>
A Uint8Array bytes representation of the screenshot.
Call Signature
Parameters
Returns
Promise<Blob>
A Blob representation of the screenshot.
Call Signature
Parameters
Returns
Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
A ReadableStream of bytes representation of the screenshot.
scroll()
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>
updateNetwork()
Parameters
Returns
Promise<void>
uploadUrl()
Parameters
Returns
Promise<string>
URL for uploading file.
wait()
Parameters
Returns
Promise<void>
waitAndVerify()
Parameters
Returns
Promise<boolean>
true if the command returned the result within the timeout, otherwise false.
write()
Parameters
Returns
Promise<void>
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
desktop sandbox template.
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
Call Signature
Type Parameters
Parameters
Returns
Promise<InstanceType<S>>
sandbox instance for the new sandbox.
Example
createSnapshot()
Parameters
Returns
Promise<SnapshotInfo>
snapshot information including the snapshot name that can be used with Sandbox.create().
Throws
SandboxError withstatusCode 400 when mode: 'filesystem'
is requested but the feature is not enabled for the team
(snapshot_filesystem_only_disabled), and with statusCode 409 when the
sandbox’s node runs an orchestrator that predates the option
(snapshot_filesystem_only_unsupported_node). A full memory snapshot
still works in both cases; for 409, pause and resume the sandbox and retry.
deleteSnapshot()
Parameters
Returns
Promise<boolean>
true if the snapshot was deleted, false if it was not found.
fork()
count new sandboxes are created from that snapshot. All forks boot from
the same snapshot, so the snapshot is captured once regardless of count.
Each fork succeeds or fails independently — the returned array contains
one entry per requested fork, either a running Sandbox instance or
an Error describing why that fork failed to start
(Promise.allSettled-style). Per-fork error codes map to the same error
classes as other API errors (e.g. 429 to RateLimitError).
Type Parameters
Parameters
Returns
Promise<(Error | InstanceType<S>)[]>
array with one entry per requested fork — a sandbox instance or an error.
Example
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>
Interfaces
SandboxOpts
Configuration options for the Sandbox environment. SandboxOptsProperties
allowInternetAccess?
False, it works the same as setting network denyOut to [0.0.0.0/0].
apiHeaders?
apiKey?
Default
display?
domain?
Default
E2B_DOMAIN // environment variable ore2b.app
dpi?
envs?
envs argument when executing commands or code.
Default
headers?
Deprecated
UseapiHeaders instead.
httpVersion?
'2' multiplexes streams over shared connections;
'1.1' pins them to HTTP/1.1 with one connection per concurrent
request — for example when an intermediary on the path retires or
mishandles long-lived HTTP/2 connections. Only applies in Node.
Default
E2B_HTTP_VERSION // environment variable or'2'
iam?
tokens map enables workload identity for the sandbox.
Registered tokens are exposed to SandboxNetworkOpts.rules
transform callbacks as iam.tokens.<name> placeholders, which the egress
proxy resolves per request.
Example
lifecycle?
logger?
Logger interface—for example, console.
mcp?
Default
metadata?
Default
network?
proxy?
Example
requestTimeoutMs?
Default
resolution?
retries?
TypeError) is retried too. A 502 and those network errors are not
retried for operations that create a resource (e.g. sandbox creation) or
append to one (secret update), as the server may already have processed
them.
A 429 is retried only with a valid, non-negative integer delta-seconds
Retry-After header (HTTP-date and malformed values are not retried).
502 and 503 honor such a Retry-After when present; otherwise they and
connection failures use exponential backoff with jitter starting at
100 ms (capped at 10 s).
Retry waits use a 60-second total limit when request timeouts are disabled.
Default
sandboxUrl?
secure?
Deprecated
Every sandbox secures envd access; this option is accepted for backward compatibility and ignored.signal?
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
template?
Default
‘base’ (or ‘mcp-gateway’ whenmcp option is set)
timeoutMs?
validateApiKey?
Deprecated
The API key format is no longer validated on the client side; this option has no effect.volumeMounts?
Volume instance or a string representing the volume name.