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
/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
templateCodestringRequiredUnique template code, that is, the templateID returned by the create template operation.
Request body
namestringOptionalTemplate name. The existing name is kept when omitted.
cpuCountintegerOptionalNumber of vCPUs. Must be passed together with memoryMB. The existing specification is kept when omitted.
memoryMBintegerOptionalMemory size in MB. Must be passed together with cpuCount. The existing specification is kept when omitted.
fromImagestringOptionalBase image. The existing image is kept when omitted.
imageNamestringOptionalImage display name. The existing display name is kept when omitted.
mntConfigarray<object>OptionalFile 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).
networkConfigobjectOptionalNetwork 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).
envConfigobjectOptionalReplaces the environment variables with the key-value pairs passed in this request. Values are strings.
autoPauseTimeintegerOptionalAuto-pause time on expiry, in seconds. Valid range: [300,604800].
maxRunningTimeoutintegerOptionalMaximum running time in seconds. Valid range: [300,604800].
descriptionstringOptionalTemplate description.
Response fields
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.
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"
}