跳转到内容
返回主页

Sandboxes

生命周期接口用于创建隔离运行时、重连、暂停、延长 TTL 和删除沙箱。

POST /sandboxes

请求体:

字段类型必填说明
templateIDstring模板 ID 或官方类型,例如 basecode-interpreternodecodexapi-server。为空时使用默认 base 模板。公开官方列表见模板指南。
timeoutinteger生命周期 TTL,单位秒。
waitReadyboolean等待沙箱 ready 后再返回。
metadataobject作为沙箱 label 持久化的键值元数据。
envVarsobject创建时注入的环境变量。
autoPauseboolean超时后暂停,而不是直接 kill。
autoResumeboolean允许 router 访问暂停沙箱时触发自动恢复。
allowInternetAccessbooleanE2B 风格出网控制。
network.allowPublicTrafficbooleanfalse 时,公网预览需要 traffic token。
network.allowInternetAccessbooleannetwork 对象内的出网控制。
network.allowOutstring[]IPv4/CIDR 出站 allowlist。
network.denyOutstring[]IPv4/CIDR 出站 denylist。
volumeMountsobject[]请求级卷挂载,每项为 { "name": "...", "path": "/..." }

不要在创建请求中传 timeoutMssecuremcp 或 snake_case volume_mountstimeout 单位是秒;运行时命令请求仍使用毫秒级 timeoutMs

Terminal window
export SEACLOUD_API_BASE_URL="https://sandbox-service.real-cloud.seaart.ai/api/v1/sandbox"
curl -sS -X POST "$SEACLOUD_API_BASE_URL/sandboxes" \
-H "X-API-Key: $SEACLOUD_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"timeout": 1800,
"waitReady": true,
"metadata": { "app": "agent" }
}'

响应:

{
"templateID": "tpl-base-...",
"sandboxID": "sandbox_...",
"envdAccessToken": "<opaque-token>",
"envdUrl": "https://sandbox-router.example/9000-sandbox_...",
"status": "running",
"state": "running",
"startedAt": "2026-06-10T08:55:50Z",
"activatedAt": "2026-06-10T08:55:50Z",
"endAt": "2026-06-10T09:25:50Z",
"timeline": []
}
GET /sandboxes

常用查询参数:

Query说明
state生命周期状态过滤,可重复或逗号分隔。
metadata[key]元数据过滤。
limit分页大小。
nextToken上一页返回的分页 token。
GET /sandboxes/:sandboxID

返回详情、生命周期时间、运行时访问参数、timeline 和可选 diagnostic

POST /sandboxes/:sandboxID/connect

请求体:

{
"timeout": 1800
}

请求体和 timeout 字段都是必需的。timeout=0 表示保持现有 TTL;正数表示从重连时间开始重置 TTL。该控制面接口会拒绝 timeoutMs

MethodPath说明
POST/sandboxes/:sandboxID/pause暂停运行时并保留可恢复状态。
POST/sandboxes/:sandboxID/refreshes使用平台默认值或 duration 延长生命周期。
POST/sandboxes/:sandboxID/timeout使用 { "timeout": 3600 } 设置 TTL。
DELETE/sandboxes/:sandboxID删除沙箱。

POST /sandboxes/:sandboxID/timeout 同样要求 JSON body 中包含 timeout,并会拒绝 timeoutMs

MethodPath说明
GET/sandboxes/:sandboxID/logs日志查询,支持 limitcursordirectionlevelsearch
GET/sandboxes/:sandboxID/metrics单个沙箱最新指标。
GET/sandboxes/metrics批量指标。