Update environment template

Updated at:

Update an environment template; omitted fields keep their current values.

Endpoint

Returns 200 and the complete updated environment template. Omitted fields keep their current values.

POST/agents/environments/templates/{template_id}

Path parameters

template_idstringRequired

Environment template ID

Request body

namestring / nullOptional

Template name

packagesobjectOptional

Packages grouped by npm, python, and system

envobject<string,string>Optional

Environment variables; the same name and value limits apply as at template creation

setup_commandsarrayOptional

Setup commands executed in order

networkobjectOptional

Network policy with access and allowed_domains; blocked_domains is not accepted

desktopobjectOptional

Desktop settings; only enabled=false is accepted, and enabled=true returns 400

capability_directoriesarray<string>Optional

Capability discovery directories

skillsarrayOptional

Skill configuration, fixed as skill_reference

pluginsarrayOptional

Plugin configuration; only an empty array is supported, and non-empty arrays return 400

filesarrayOptional

Initial file configuration, fixed as file_id

When only name is provided, existing network, capability_directories, and other configuration remain unchanged.

An explicit null resets the field: name is cleared, network returns to the default policy, desktop returns to enabled=false, and array fields are cleared.

Request example

curl -sS -X POST "$BASE_URL/agents/environments/templates/envtmpl_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "OpenAI-Beta: agents=v1" \
  -H "Content-Type: application/json" \
  -d '{"name": "example-template-v2"}'
template = client.beta.agents.environments.templates.update(
    "envtmpl_xxx",
    name="example-template-v2",
)
print(template.updated_at)

Response fields

idstring

Environment template ID

objectstring

Environment template object type, fixed as agent.environment.template

namestring / null

Template name

created_atinteger

Creation time in Unix seconds

updated_atinteger

Last update time in Unix seconds

packagesobject

Packages with python, system, and npm

networkobject

Network policy with access and allowed_domains

desktopobject

Desktop settings with enabled

capability_directoriesarray<string>

Capability discovery directories

skillsarray

Skill configuration with type, skill_id, and version

pluginsarray

Safe plugin metadata. Contains type, name, and description; currently an empty array

filesarray

Initial file configuration; each item contains type, path, and file_id

Responses do not return env or setup_commands.

Response example

{
  "id": "envtmpl_xxx",
  "name": "example-template-v2",
  "object": "agent.environment.template",
  "created_at": 1794319007,
  "updated_at": 1794319102,
  "packages": {"python": [], "system": [], "npm": []},
  "network": {"access": "disabled", "allowed_domains": []},
  "desktop": {"enabled": false},
  "capability_directories": ["/workspace/skills"],
  "skills": [],
  "plugins": [],
  "files": []
}

Error codes

HTTP statusError type / codeSolution
400invalid_request_error / invalid_request_errorFix the request body as described for each field
400invalid_request_error / invalid_request_errordesktop.enabled=true, non-empty plugins, and network.blocked_domains are rejected; adjust the field accordingly
401authentication_error / invalid_api_keySend a valid Authorization: Bearer $DASHSCOPE_API_KEY header
404not_found_error / not_found_errorUse an environment template ID that exists in the current workspace
500server_error / server_errorRetry later. If it keeps failing, submit a ticket with x-request-id