Create a sandbox template. On success, the response returns templateID and buildID. Wait until the build status becomes ready before you create an instance.
Prerequisites
Configure the endpoint and authentication first. See API overview and authentication.
Endpoint
POST /v3/templates
Create a sandbox template. The route POST /templates is also supported. On success, the response returns templateID and buildID. Wait until the build status becomes ready before you create an instance. cpuCount and memoryMB must be passed together and must match a resource specification supported by the platform. Invalid JSON returns an explicit format error.
Request body
| Field | Required | Type | Description |
|---|---|---|---|
name | Yes | string | Template name. |
cpuCount | Yes | integer | Number of vCPUs. Must be greater than 0 and, together with the memory size, match a resource specification supported by the platform. |
memoryMB | Yes | integer | Memory size in MB. Must be greater than 0 and, together with the CPU count, match a resource specification supported by the platform. |
fromImage | No | string | Base image, specified as a full image address. Official images are under fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/: code-interpreter-v1, browser, and all-in-one. The platform default image (code interpreter) is used when omitted. |
imageName | No | string | Image display name. |
tags | No | array<string> | E2B tags. |
alias | No | string | E2B template alias. |
mntConfig | No | array<object> | File mount configuration. 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). |
networkConfig | No | object | Network rules. 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). |
envConfig | No | object | Environment variable key-value pairs written into the template runtime. Values are strings. |
autoPauseTime | No | integer | Auto-pause time on expiry, in seconds. Valid range: [300,604800]. |
maxRunningTimeout | No | integer | Maximum running time in seconds. Valid range: [300,604800]. The instance is released automatically on expiry. If only autoPauseTime is set, the instance is paused on expiry; if both are set, maxRunningTimeout takes effect; if neither is set, the maximum running time defaults to 604800 seconds. |
description | No | string | Template description. |
Request example
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 202 on success, which means the template has been submitted for building.
Response fields
| Field | Type | Description |
|---|---|---|
templateID | string | Template ID. |
templateName | string | Template name. |
templateType | string | Template type, for example CUSTOM. |
cpuCount | integer | Number of vCPUs. |
memoryMB | integer | Memory size in MB. |
public | boolean | Whether the template is public. |
regionId | string | Region. |
imageName | string | Image display name. |
buildID | string | Build ID, used to query the build status. |
buildStatus | string | Build status, for example building. |
createdAt | string | Creation time in date-time format. |
updatedAt | string | Update time in date-time format. |
version | integer | Template version number. |
tags | array<string> | Tags. Not treated as a persisted field until it is returned reliably by subsequent list and get template calls. |
aliases | array<string> | Alias list. Not treated as a persisted field until it is returned reliably by subsequent list and get template calls. |
You can create an instance from the template only after the build status becomes
ready. See Get build status.