Update template

Updated at:

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

templateCodestringRequired

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

Request body

namestringOptional

Template name. The existing name is kept when omitted.

cpuCountintegerOptional

Number of vCPUs. Must be passed together with memoryMB. The existing specification is kept when omitted.

memoryMBintegerOptional

Memory size in MB. Must be passed together with cpuCount. The existing specification is kept when omitted.

fromImagestringOptional

Base image. The existing image is kept when omitted.

imageNamestringOptional

Image display name. The existing display name is kept when omitted.

mntConfigarray<object>Optional

File mount configuration. File IDs are re-validated when passed. Sub-fields: originFileName (string, optional, original file name; ignored when mountPath is a directory), originFileId (string, required, ID of a file uploaded with source=sandbox_template and in available status), mountPath (string, required, must start with /home/user/workspace/uploads/; a full file path is recommended. If the path is outside this directory, the API accepts the configuration but the file does not appear in the instance. For upload details, see File upload).

networkConfigobjectOptional

Network 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).

envConfigobjectOptional

Replaces the environment variables with the key-value pairs passed in this request. Values are strings.

autoPauseTimeintegerOptional

Auto-pause time on expiry, in seconds. Valid range: [300,604800].

maxRunningTimeoutintegerOptional

Maximum running time in seconds. Valid range: [300,604800].

descriptionstringOptional

Template description.

Response fields

templateIDstring

Template ID, unchanged before and after the update.

templateNamestring

Template name.

cpuCountinteger

Number of vCPUs.

memoryMBinteger

Memory size in MB.

buildIDstring

Build ID of the new version, used to query the build status.

buildStatusstring

Build status, which may be building.

versioninteger

Template version number, incremented after each successful update.

createdAtstring

Time the template was first created, in date-time format.

updatedAtstring

Time of this update, in date-time format.

NoteFiles in mntConfig must first be uploaded through the file upload operation with source=sandbox_template. For details, see File upload.

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