Create an environment
Updated at:
Create a runtime environment. The request body defines the sandbox type, preinstalled dependencies, and network policy; the response returns the full Environment object.
Prerequisites
Endpoint and authentication are configured. See Overview and authentication.
Endpoint
POST /environments
Request body
| Field | Required | Type | Description |
|---|---|---|---|
name | Yes | string | Unique identifier within the workspace |
description | No | string | Description of the environment's purpose |
scope | No | string | Scope of the environment. organization: visible to and reusable by all members of the workspace. Defaults to organization |
config.type | No | string | Sandbox type. cloud = cloud container. Immutable after creation. Defaults to cloud when config is omitted |
config.packages | No | object | Preinstalled dependencies grouped by package manager. Keys are apt | pip | npm; values are arrays of package names |
config.networking | No | object | Network policy object, shaped as {"type": "unrestricted"}. Currently only unrestricted outbound access is supported |
metadata | No | object | Custom business key-value pairs; do not affect runtime behavior |
Request example
curl -X POST "$AGENTSTUDIO_URL/environments" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "data-sandbox",
"description": "Data analysis sandbox",
"scope": "organization",
"metadata": {"team": "infra"},
"config": {
"type": "cloud",
"packages": {
"apt": ["ffmpeg"],
"pip": ["pandas", "numpy", "matplotlib"]
},
"networking": {"type": "unrestricted"}
}
}'
env = client.environments.create(
name="data-sandbox",
config={
"type": "cloud",
"networking": {"type": "unrestricted"},
"packages": {
"apt": ["ffmpeg"],
"pip": ["pandas", "numpy", "matplotlib"],
},
},
description="Data analysis sandbox",
scope="organization",
metadata={"team": "infra"},
)
Environment env = client.environments().create(EnvironmentCreateParam.builder()
.name("data-sandbox")
.description("Data analysis sandbox")
.build());
Response example
{
"id": "env_xxx",
"type": "environment",
"name": "data-sandbox",
"description": "Data analysis sandbox",
"scope": "organization",
"config": {
"type": "cloud",
"packages": {"apt": ["ffmpeg"], "pip": ["pandas", "numpy", "matplotlib"]},
"networking": {"type": "unrestricted"}
},
"metadata": {"team": "infra"},
"archived_at": null,
"created_at": "2026-06-16T12:45:34+08:00",
"updated_at": "2026-06-16T12:45:34+08:00",
"requestId": "xxx"
}
The response is an Environment object. Fields:
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Environment ID, format env_ + base64-encoded string, for example env_N2M2OTc4NTY4ZjRkNDEwZT |
type | string | Fixed value environment |
name / description / scope / config / metadata | string / object | Same as the request body; config contains the full runtime configuration (sandbox type, preinstalled dependencies, network policy) |
archived_at | string | null | Archive time; null when not archived |
created_at / updated_at | string | Creation / last update time, ISO 8601 |
requestId | string | Unique identifier for this request |
Is this page helpful?