跳转到内容
EN

复制沙箱

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

POST/e2b/sandboxes/{sandboxID}/fork● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger可选
    默认 15

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

  • countinteger可选
    默认 1

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

返回

201

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

请求示例

curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/e2b/sandboxes/sbx_123/fork \
  -H "X-API-Key: $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"count":1}'
Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
from e2b import Sandbox

opts = dict(
    api_key="$PRAXIS_API_KEY",
    api_url="https://api.deepraxis.com/e2b",
    domain="sandbox.praxisusercontent.com",
)

children = Sandbox.fork("sbx_123", count=1, **opts)
print(children)
TypeScript
// 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import { Sandbox } from "e2b";

const opts = {
  apiKey: "$PRAXIS_API_KEY",
  apiUrl: "https://api.deepraxis.com/e2b",
  domain: "sandbox.praxisusercontent.com",
};

const children = await Sandbox.fork("sbx_123", { ...opts, count: 1 });
console.log(children);

响应示例 201

[
  {
    "sandbox": {
      "templateID": "node22",
      "sandboxID": "sbia970bfef1c540f18f7a4f4da",
      "clientID": "iyhdmes2si5kag4oj015m",
      "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.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
[].error object
[].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 Error