连接沙箱
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
POST
/sandbox/v1/sandboxes/{sandboxID}/connect● 支持请求参数
sandboxIDstring必填path: 沙箱 ID。
timeoutinteger可选Requested remaining lifetime in seconds from the connection. Defaults to 300 seconds; an existing later expiry is preserved.
memoryboolean可选Defaults to true. When false and the sandbox is paused, resume from disk state only: the sandbox cold-boots fresh and any memory in the snapshot is ignored, never modified or deleted. Disk state has crash-recovery semantics — writes not flushed before the pause may be lost. A no-op for snapshots that contain no memory. Rejected with an error in environments where this capability is not enabled, never silently downgraded to a memory restore.
返回
201
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/connect \
-H "X-API-Key: $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timeout":300}'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/connect",
headers={"X-API-Key": api_key},
json={"timeout": 300},
)
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/connect`, {
method: "POST",
headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
body: JSON.stringify({ timeout: 300 }),
});
console.log(resp.status, await resp.text());响应示例 201
{
"templateID": "node22",
"sandboxID": "sbib2586b83c183533da70bced2",
"clientID": "i42g6lkj181tyvouozh1o",
"envdVersion": "0.9.0",
"envdAccessToken": "<access-token>",
"domain": "sandbox.praxisusercontent.com"
}响应
HTTP 200
The sandbox was already running
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 |
| 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. |
HTTP 201
The sandbox was resumed 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 |
| 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. |