创建沙箱
从模板创建一个沙箱,返回沙箱 ID 与数据面访问凭证。
/sandbox/v1/sandboxes● 支持请求体
templateIDstring必填Identifier of the required template
timeoutinteger可选Lifetime of the new sandbox in seconds. Defaults to 300 seconds when omitted.
autoPauseboolean可选Automatically pauses the sandbox after the timeout
metadataany可选Your own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.
envVarsany可选Environment variables as name to value string pairs.
allow_internet_accessboolean可选Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config.
autoPauseMemoryboolean可选Controls the snapshot kind taken when the sandbox auto-pauses on timeout (only relevant when autoPause is true). When false, the auto-pause drops the in-memory state and persists only the filesystem (a filesystem-only snapshot); resuming it cold-boots (reboots) the sandbox from disk. Such a snapshot cannot be auto-resumed by traffic and must be resumed explicitly, so it cannot be combined with autoResume. Defaults to true (full memory snapshot).
autoResumeobject可选Auto-resume configuration for paused sandboxes.
▸ 展开子字段(1)
enabledboolean必填Auto-resume enabled flag for paused sandboxes. Default false.
networkobject可选Network policy of the sandbox: public access, egress allow and deny lists and proxy.
▸ 展开子字段(7)
allowPublicTrafficboolean可选Specify if the sandbox URLs should be accessible only with authentication.
allowOutarray可选List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.
denyOutarray可选List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.
egressProxyobject可选SOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).
maskRequestHoststring可选Specify host mask which will be used for all sandbox requests
httpsPortsarray可选Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.
rulesobject可选Per-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, "*.example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "*" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.
mcpobject可选MCP configuration for the sandbox
▸ 更多参数(2)
iamobject可选Sandbox workload identity configuration. A non-empty, valid tokens map enables workload identity for the sandbox.
▸ 展开子字段(1)
tokensobject可选Named workload-token definitions, keyed by a caller-chosen token name.
volumeMountsarray可选Volumes to mount into the sandbox, each with the volume name and the path inside the sandbox.
▸ 展开子字段(2)
namestring必填Name of the volume
pathstring必填Path of the volume
返回
201
平台暂未提供 E2B 默认的 base 模板:不带模板参数的 Sandbox.create() 会返回 404,请显式指定模板(可用模板见「列出模板」)。
错误按 E2B 格式返回,参见 错误码
响应
HTTP 201
The sandbox was created successfully
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| templateID | string | Identifier of the template from which is the sandbox created |
| sandboxID | string | Identifier of the sandbox |
| alias | string | Alias of the template |
| clientID | string | Identifier of the client |
| envdVersion | string | Version of the envd running in the sandbox |
| envdAccessToken | string | Access token used for envd communication |
| trafficAccessToken | string | Token required for accessing sandbox via proxy. |
| domain | string | Base domain where the sandbox traffic is accessible |