跳转到内容
EN

升级为完整沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST/sandbox/v1/sandboxes/{sandboxID}/upgrade● 支持

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • templateIDstring可选
    默认 "base"

    目标模板,默认 base(node22 别名);必须包含 E2B 镜像,否则返回 INVALID_PARAMS。升级期间文件、进程与数据面操作返回 409。

返回

200

错误按 E2B 格式返回,参见 错误码

请求示例

curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/upgrade \
  -H "X-API-Key: $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"templateID":"base"}'
Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import requests

api_key = "$PRAXIS_API_KEY"

# Call /sandbox/v1 directly over HTTP.
resp = requests.post(
    "https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/upgrade",
    headers={"X-API-Key": api_key},
    json={"templateID": "base"},
)
print(resp.status_code, resp.text)
TypeScript
// 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
const apiKey = "$PRAXIS_API_KEY";

// Call /sandbox/v1 directly over HTTP.
const resp = await fetch(`https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/upgrade`, {
  method: "POST",
  headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify({ templateID: "base" }),
});
console.log(resp.status, await resp.text());

响应示例 200

{
  "sandboxID": "sbie4eda4c56407f4b608faaa84",
  "templateID": "base",
  "clientID": "ivo02hf010oiz5r6hggy4",
  "startedAt": "2026-10-11T10:34:38.467Z",
  "endAt": "2026-10-11T10:35:37.762Z",
  "state": "running",
  "cpuCount": 2,
  "memoryMB": 4096,
  "diskSizeMB": 10240,
  "envdVersion": "0.9.0",
  "envdAccessToken": "<redacted>",
  "domain": "sandbox.praxisusercontent.com",
  "metadata": {},
  "allowInternetAccess": null,
  "volumeMounts": [],
  "lifecycle": {
    "onTimeout": "kill",
    "autoResume": false
  },
  "capabilities": {
    "exec": "posix",
    "pty": "full",
    "metrics": true,
    "backgroundProcess": true,
    "upgradeTo": [],
    "preview": "domain",
    "network": true
  },
  "name": "docs-k16-sample",
  "ephemeral": false,
  "keepMemory": true
}

响应

HTTP 200

Upgraded sandbox detail with a replacement access token

application/json

名称 类型 说明
templateID string Identifier of the template from which is the sandbox created
alias string Alias of the template
sandboxID string Identifier of the sandbox
clientID string Identifier of the client
startedAt string Time when the sandbox was started
endAt string Time when the sandbox will expire
envdVersion string Version of the envd running in the sandbox
envdAccessToken string Access token used for envd communication
allowInternetAccess boolean Whether internet access was explicitly enabled or disabled for the sandbox. Null means it was not explicitly set.
domain string Base domain where the sandbox traffic is accessible
cpuCount integer Requested virtual CPU count; a positive integer, default 2 for template builds.
memoryMB integer Requested build memory in MiB; a positive integer, default 1024.
diskSizeMB integer Disk size for the sandbox in MiB
metadata any Your own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.
state string running while the sandbox's machine is up and drivable, paused while it is stopped and can be resumed. On the own face an android phone (templateID "android") has three device states of its own, because its machine running is not yet the phone program's readiness: starting while the vendor is still building the machine, booting while the machine runs but the phone program has not connected on the sandbox's control connection, and running once it has. Its detail and list rows also carry readyAt, the epoch-milliseconds instant the program said hello, null until it does; a linux sandbox only ever reads running or paused.
network object Network policy of the sandbox: public access, egress allow and deny lists and proxy.
network.allowPublicTraffic boolean Specify if the sandbox URLs should be accessible only with authentication.
network.allowOut array<string> 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.
network.denyOut array<string> List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.
network.egressProxy object 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).
network.maskRequestHost string Specify host mask which will be used for all sandbox requests
network.httpsPorts array<integer> Unlike E2B, network.httpsPorts is rejected; omit it when creating a sandbox.
network.rules object 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.
network.staticEgressIp boolean Own face, persistent sandboxes only (autoPause: true, or ephemeral: false): true gives the sandbox one fixed public egress IP for its whole life, held through pause and resume and released when the sandbox is deleted. Without it the egress IP is not stable: it changes when a spot machine is reclaimed, when a paused machine starts again, and when the machine is rebuilt. An ephemeral sandbox returns INVALID_PARAMS; the E2B face refuses the field; it is placed only on capacity that declares static IPs, and without such capacity the create does not start (it never falls back to a changing IP). Billed as the usage item sandbox:public_ip:hours from allocation to release, paused time included, plus outbound traffic as usual.
network.egressIp string Own face, read-only: the fixed public egress IP of a sandbox created with staticEgressIp: true, present once the machine has bound it; add this address to the IP allowlist of the service you call (for example a WeCom trusted IP list). Absent on a sandbox that did not ask for a static IP, because its public address can change.
lifecycle object Sandbox lifecycle policy returned by sandbox info.
lifecycle.autoResume boolean Whether the sandbox can auto-resume.
lifecycle.onTimeout string Action taken when the sandbox times out.
volumeMounts array<object> Volumes mounted into the sandbox.
volumeMounts[].name string Name of the volume
volumeMounts[].path string Path of the volume