跳转到内容
EN

复制沙箱

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

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

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • timeoutinteger可选
    默认 15

    新副本的存活时间,单位为秒。

  • countinteger可选
    默认 1

    要创建的独立副本数。所有副本来自同一次快照,每个副本分别返回成功结果或错误。

返回

201

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

请求示例

curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/fork \
  -H "X-API-Key: $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"count":1}'
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/fork",
    headers={"X-API-Key": api_key},
    json={"count": 1},
)
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/fork`, {
  method: "POST",
  headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify({ count: 1 }),
});
console.log(resp.status, await resp.text());

响应示例 201

[
  {
    "sandbox": {
      "templateID": "node22",
      "sandboxID": "sbia61f57b1656b1d1dda4e017c",
      "clientID": "ilw3r38pwlahgkvdu85yc",
      "envdVersion": "0.9.0",
      "envdAccessToken": "<access-token>",
      "domain": "sandbox.praxisusercontent.com"
    }
  }
]

响应

HTTP 201

The sandbox was snapshotted and the forks were attempted; each entry reports one fork’s outcome

application/json

名称 类型 说明
[].sandbox object Sandbox created from a template.
[].sandbox.templateID string Identifier of the template from which is the sandbox created
[].sandbox.sandboxID string Identifier of the sandbox
[].sandbox.alias string Alias of the template
[].sandbox.clientID string Identifier of the client
[].sandbox.envdVersion string Version of the envd running in the sandbox
[].sandbox.envdAccessToken string Access token used for envd communication
[].sandbox.trafficAccessToken string Token required for accessing sandbox via proxy.
[].sandbox.domain string Base domain where the sandbox traffic is accessible
[].sandbox.machine string What kind of machine this sandbox is, so you can decide whether to drive it as a computer without knowing which vendor placed it. full: a complete environment that runs files, commands, terminals and background processes through the data plane — drive it as a computer. light: a light machine without that. none: a single-use box that is reachable but must not be driven as a computer.
[].error object Error body: numeric code, machine-readable error_code and a message.
[].error.code integer Error code
[].error.error_code string Machine-readable semantic error code. Not a closed set; initial values: sandbox_capacity_unavailable, sandbox_placement_timeout, sandbox_no_compatible_node, sandbox_create_failed, internal_server_error.
[].error.message string Human-readable description of the error.