Skip to main content

Update Environment

Uses partial update semantics: fields included in the request are updated, while omitted fields retain their original values. Active sessions use the snapshot bound at creation time; new sessions use the updated environment.

Prerequisites

Endpoint and authentication are configured. See Overview and authentication.

Endpoint

POST /environments/{environment_id}

Semantics

Uses partial update semantics: fields included in the request body are updated, while omitted fields retain their original values. Active sessions bound to this environment use the snapshot from binding time and are not affected by the update; new sessions use the updated environment.
  • config.type is immutable; passing a different value will cause an error.
  • config.packages is replaced as a whole when provided (including sub-keys apt, pip, etc.); unlisted packages will be removed.
  • metadata is replaced as a whole when provided; key-level merging is not performed.

Request body

Fields are the same as in the Request body section of Create an environment; only include the fields you want to update.

Request example

curl -X POST "$AGENTSTUDIO_URL/environments/env_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "data-sandbox",
    "description": "数据分析沙箱(更新)",
    "scope": "organization",
    "metadata": {"team": "infra"},
    "config": {
      "type": "cloud",
      "packages": {"apt": ["ffmpeg"], "pip": ["pandas", "numpy", "scikit-learn"]},
      "networking": {"type": "unrestricted"}
    }
  }'

Response example

{
  "id": "env_xxx",
  "type": "environment",
  "name": "data-sandbox",
  "description": "数据分析沙箱(更新)",
  "config": {
    "type": "cloud",
    "packages": {"apt": ["ffmpeg"], "pip": ["pandas", "numpy", "scikit-learn"]},
    "networking": {"type": "unrestricted"}
  },
  "metadata": {"team": "infra"},
  "scope": "organization",
  "archived_at": null,
  "created_at": "2026-06-16T12:45:34+08:00",
  "updated_at": "2026-06-16T12:52:31+08:00",
  "request_id": "xxx"
}
The response is the updated Environment object. Fields are as follows:

Response fields

FieldTypeDescription
idstringEnvironment ID
typestringFixed value environment
name / description / scope / config / metadatastring / objectUpdated environment configuration; omitted fields retain their original values
archived_atstring | nullArchive time; null when not archived
created_at / updated_atstringCreation / last update time, ISO 8601
request_idstringUnique identifier for this request
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration