列举实例

更新时间:
复制 MD 格式

列举当前工作空间下的沙箱实例,支持按模版 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

cpuCountinteger

vCPU 核数

memoryMBinteger

内存大小,单位 MB

diskSizeMBinteger

磁盘大小,单位 MB

envdVersionstring

envd 版本

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"}
  }
]