Create a reusable environment template that stores container, dependency, network, initial file, and skill configuration.
Endpoint
POST /agents/environments/templates
Returns 201 and the complete environment template. The request body can be empty; in that case the template is created with default configuration.
Request body
| Field | Required | Type | Description |
|---|---|---|---|
name | No | string / null | Template name |
packages | No | object | Packages grouped by npm, python, and system; all three groups default to empty arrays |
env | No | object<string,string> | Environment variables; names must match [A-Za-z_][A-Za-z0-9_]*, cannot be PATH, and cannot start with a server-reserved prefix; values cannot contain NUL |
setup_commands | No | array | Setup commands executed in order. Each item requires command and accepts an optional cwd; cwd defaults to /workspace |
network | No | object | Network policy, defaults to enabled; blocked_domains is not accepted |
desktop | No | object | Desktop settings; only enabled=false is accepted, and enabled=true returns 400 |
capability_directories | No | array<string> | Capability discovery directories, defaults to [] |
skills | No | array | Skill configuration, fixed as skill_reference |
plugins | No | array | Plugin configuration; only an empty array is supported, and non-empty arrays return 400 |
files | No | array | Initial file configuration, fixed as file_id |
packages.python | No | array<string> | Python packages |
packages.system | No | array<string> | System packages |
packages.npm | No | array<string> | npm packages |
setup_commands.command | No | string | Setup command |
setup_commands.cwd | No | string | Working directory, defaults to /workspace |
network.access | No | string | Network access mode, enabled, disabled, or restricted |
network.allowed_domains | No | array<string> | Allowed domains when access=restricted |
desktop.enabled | No | boolean | Whether the desktop is enabled |
env or setup_commands. files is always file_id, and skills is always skill_reference.
Request example
Response example
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Environment template ID |
object | string | Environment template object type, fixed as agent.environment.template |
name | string / null | Template name |
created_at | integer | Creation time in Unix seconds |
updated_at | integer | Last update time in Unix seconds |
packages | object | Packages with python, system, and npm |
network | object | Network policy with access and allowed_domains |
desktop | object | Desktop settings with enabled |
capability_directories | array<string> | Capability discovery directories |
skills | array | Skill configuration with type, skill_id, and version |
plugins | array | Safe plugin metadata. Contains type, name, and description; currently an empty array |
files | array | Initial file configuration; each item contains type, path, and file_id |
Error codes
| HTTP status | Error type / code | Solution |
|---|---|---|
400 | invalid_request_error / invalid_request_error | Fix the request body as described for each field |
400 | invalid_request_error / invalid_request_error | desktop.enabled=true, non-empty plugins, and network.blocked_domains are rejected; adjust the field accordingly |
401 | authentication_error / invalid_api_key | Send a valid Authorization: Bearer $DASHSCOPE_API_KEY header |
500 | server_error / server_error | Retry later. If it keeps failing, submit a ticket with x-request-id |