列举当前工作空间下的沙箱实例,支持按模版 ID、实例 ID 与状态过滤。兼容 E2B 列举实例协议。
前提
已完成 Endpoint 与鉴权配置,详见API 总览与认证。
接口
GET
/v2/sandboxes列举当前工作空间下的沙箱实例。兼容 E2B 列举实例协议,兼容路由 GET /sandboxes。
查询参数
templateIDstring可选按模版 ID 过滤。兼容 templateId、template
sandboxIDstring可选按实例 ID 精确过滤
statestring可选按状态过滤,例如 running、paused
limitinteger可选单页条数,默认 20,最大 50
响应字段
数组元素字段如下。
clientIDstring客户端标识
sandboxIDstring实例唯一 ID
bailianSandboxIdstring阿里云百炼扩展标识;开发者通常无需使用
templateIDstring模版 ID
aliasstring模版别名
statestring实例状态,例如 running
cpuCountintegervCPU 核数
memoryMBinteger内存大小,单位 MB
diskSizeMBinteger磁盘大小,单位 MB
envdVersionstringenvd 版本
startedAtstring实例启动时间,date-time 格式
endAtstring实例到期时间,date-time 格式
metadataobject自定义元数据
请求示例
curl -X GET "$BASE_URL/v2/sandboxes?state=running&limit=20" \
-H "Authorization: Bearer $BAILIAN_API_KEY"
其中 BASE_URL 为 https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sandbox,BAILIAN_API_KEY 为阿里云百炼 API Key。
响应示例
响应体直接返回实例数组,不封装为分页对象。
[
{
"clientID": "your-client-id",
"sandboxID": "sbx-xxx",
"bailianSandboxId": "your-bailian-sandbox-id",
"templateID": "your-template-id",
"alias": "your-template-alias",
"state": "running",
"cpuCount": 1,
"memoryMB": 2048,
"diskSizeMB": 10240,
"envdVersion": "your-envd-version",
"startedAt": "2026-01-01T00:00:00Z",
"endAt": "2026-01-01T01:00:00Z",
"metadata": {"team": "data"}
}
]
该文章对您有帮助吗?