Skip to main content

Update template

Update the configuration of a specific template. The templateID stays unchanged, version increments after each successful update, and a new build is submitted.

Prerequisites

Configure the endpoint and authentication first. See API overview and authentication.

Endpoint

PUT /templates/{templateCode} Update the configuration of a specific template. This operation is an Alibaba Cloud Model Studio extension and is not declared fully compatible with E2B Update Template v2. templateID stays unchanged before and after the update, and version increments after each successful update. createdAt is the time the template was first created, and updatedAt is the time of this update. A successful update means a new build has been submitted; whether you can create instances depends on the build status.

Path parameters

ParameterRequiredTypeDescription
templateCodeYesstringUnique template code, that is, the templateID returned by the create template operation.

Request body

FieldRequiredTypeDescription
nameNostringTemplate name. The existing name is kept when omitted.
cpuCountNointegerNumber of vCPUs. Must be passed together with memoryMB. The existing specification is kept when omitted.
memoryMBNointegerMemory size in MB. Must be passed together with cpuCount. The existing specification is kept when omitted.
fromImageNostringBase image. The existing image is kept when omitted.
imageNameNostringImage display name. The existing display name is kept when omitted.
mntConfigNoarray<object>File mount configuration. File IDs are re-validated when passed. Sub-fields: originFileName (string, optional, original file name), originFileId (string, required, ID of a file that exists in the current workspace), mountPath (string, required, mount path inside the instance).
networkConfigNoobjectNetwork rules, same as in create template. Sub-fields: allowOut (array<string>, egress allowlist, supports IPv4, IPv6, CIDR, and domain names), denyOut (array<string>, egress denylist, supports IPv4, IPv6, and CIDR only — domain names are not supported).
envConfigNoobjectReplaces the environment variables with the key-value pairs passed in this request. Values are strings.
autoPauseTimeNointegerAuto-pause time on expiry, in seconds. Valid range: [300,604800].
maxRunningTimeoutNointegerMaximum running time in seconds. Valid range: [300,604800].
descriptionNostringTemplate description.

Request example

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 is https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sandbox, and BAILIAN_API_KEY is your Alibaba Cloud Model Studio API key.

Response example

Returns 200 with the updated template object. buildStatus may be building, which means a new build has been submitted.
{
  "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"
}

Response fields

FieldTypeDescription
templateIDstringTemplate ID, unchanged before and after the update.
templateNamestringTemplate name.
cpuCountintegerNumber of vCPUs.
memoryMBintegerMemory size in MB.
buildIDstringBuild ID of the new version, used to query the build status.
buildStatusstringBuild status, which may be building.
versionintegerTemplate version number, incremented after each successful update.
createdAtstringTime the template was first created, in date-time format.
updatedAtstringTime of this update, in date-time format.
Managed Agent API
Flow Agent API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration