Skip to main content
模版管理

更新模版

更新指定模版的配置。templateID 在更新前后保持不变,每次成功更新后 version 递增,并提交新一轮构建。

前提

已完成 Endpoint 与鉴权配置,详见API 总览与认证。

接口

PUT /templates/{templateCode} 更新指定模版的配置。该接口为阿里云百炼扩展协议,不声明完全兼容 E2B Update Template v2。templateID 在更新前后保持不变;每次成功更新后 version 递增。createdAt 表示模版首次创建时间,updatedAt 表示本次更新时间。更新成功表示新一轮构建已提交;是否可创建实例以构建状态为准。

路径参数

参数必填类型说明
templateCode是string模版唯一 code(即创建接口返回的 templateID)

请求体

字段必填类型说明
name否string模版名称,未传时保留原名称
cpuCount否integervCPU 数量,必须与 memoryMB 同时传;未传时保留原规格
memoryMB否integer内存大小,单位 MB,必须与 cpuCount 同时传;未传时保留原规格
fromImage否string基础镜像,未传时保留原镜像
imageName否string镜像展示名称,未传时保留原展示名称
mntConfig否array<object>文件挂载配置,传入时重新校验文件 ID。子字段 originFileName(string,选填,原始文件名)、originFileId(string,必填,当前工作空间中真实存在的文件 ID)、mountPath(string,必填,实例中的挂载路径)
networkConfig否object网络规则,与创建模版一致。子字段 allowOut(array<string>,出口白名单,支持 IPv4、IPv6、CIDR 和域名)、denyOut(array<string>,出口黑名单,仅支持 IPv4、IPv6 和 CIDR,不支持域名)
envConfig否object替换为本次传入的环境变量键值对,值为字符串
autoPauseTime否integer到期自动暂停时间,单位秒,取值范围 [300,604800]
maxRunningTimeout否integer最大运行时间,单位秒,取值范围 [300,604800]
description否string模版描述

请求示例

curl -X PUT "$BASE_URL/templates/your-template-id" \
  -H "Authorization: Bearer $BAILIAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-template-v2",
    "cpuCount": 4,
    "memoryMB": 8192,
    "envConfig": {"STAGE": "prod"},
    "description": "updated template"
  }'
其中 BASE_URL 为 https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sandbox,BAILIAN_API_KEY 为阿里云百炼 API Key。

响应示例

更新成功返回 200 与更新后的模版对象。buildStatus 可能为 building,表示新一轮构建已提交。
{
  "templateID": "your-template-id",
  "templateName": "my-template-v2",
  "cpuCount": 4,
  "memoryMB": 8192,
  "buildID": "your-new-build-id",
  "buildStatus": "building",
  "version": 2,
  "createdAt": "2026-01-01T00:00:00Z",
  "updatedAt": "2026-01-02T00:00:00Z"
}

响应字段

字段类型说明
templateIDstring模版 ID,更新前后保持不变
templateNamestring模版名称
cpuCountintegervCPU 数量
memoryMBinteger内存大小,单位 MB
buildIDstring新版本构建 ID,用于查询构建状态
buildStatusstring构建状态,可能为 building
versioninteger模版版本号,每次成功更新后递增
createdAtstring模版首次创建时间,date-time 格式
updatedAtstring本次更新时间,date-time 格式
Managed Agents
Security
RAG
应用调用
长期记忆
ParseX
框架