---
title: "更新 Environment"
method: POST
path: "/agent/managed/v1/environments/{environmentId}"
tags: ["Managed Agents - Environment"]
---

# 更新 Environment

`POST /agent/managed/v1/environments/{environmentId}`

## Request

- Base URL: `https://agent-api.bigmodel.cn/api`
- URL: `https://agent-api.bigmodel.cn/api/agent/managed/v1/environments/{environmentId}`
- Auth: HTTP bearer

更新指定 Environment 的名称、说明、元数据或云端配置。未提供的字段保持不变；归档后的 Environment 不能再绑定到新的 Session 或 Deployment。

## Path parameters

- `environmentId` string, required

## Headers

- `zai-version` '2026-05-26', required
- `zai-beta` string, required

## Request body

- ManagedEnvironmentUpdateRequest
  - `name` string: 替换名称；省略时保持不变。
  - `description` string, nullable: 替换用途说明；null 表示清空，省略时保持不变。
  - `metadata` ManagedMetadataPatch, nullable: 元数据补丁；省略整个字段时保持不变，键值为 null 时删除对应键。最多 16 个键，键名长度不超过 64 字符，字符串值不超过 512 字符。
  - `scope` 'organization', nullable: 只能为 organization；null 或省略不会改变现有作用域。
  - `config` ManagedEnvironmentConfigInput
    - `type` 'cloud', required: 当前只支持 cloud；self_hosted 会被拒绝。
    - `packages` ManagedEnvironmentPackagesInput: 声明需要预装的包；六类包管理器均可省略，省略或 null 会规范化为空数组。
      - `type` 'packages': 可选判别字段；提供时只能为 packages。
      - `apt` string[], nullable: 最多 200 个不同包名；null/省略视为空数组，重复项会去重。每项 trim 后不能为空、不能包含空白或控制字符，也不能以 - 开头。
      - `cargo` string[], nullable: 最多 200 个不同包名；null/省略视为空数组，重复项会去重。每项 trim 后不能为空、不能包含空白或控制字符，也不能以 - 开头。
      - `gem` string[], nullable: 最多 200 个不同包名；null/省略视为空数组，重复项会去重。每项 trim 后不能为空、不能包含空白或控制字符，也不能以 - 开头。
      - `go` string[], nullable: 最多 200 个不同包名；null/省略视为空数组，重复项会去重。每项 trim 后不能为空、不能包含空白或控制字符，也不能以 - 开头。
      - `npm` string[], nullable: 最多 200 个不同包名；null/省略视为空数组，重复项会去重。每项 trim 后不能为空、不能包含空白或控制字符，也不能以 - 开头。
      - `pip` string[], nullable: 最多 200 个不同包名；null/省略视为空数组，重复项会去重。每项 trim 后不能为空、不能包含空白或控制字符，也不能以 - 开头。
    - `networking` union: 网络策略。省略整个 networking 时默认为 unrestricted；所有模式的出站端口均限 HTTP/HTTPS 80/443。
      - object
        - `type` 'unrestricted', required
      - object
        - `type` 'limited', required
        - `allowed_hosts` string[], nullable: 最多 256 个不同 host；null/省略视为空数组，重复项会去重。只接受 hostname 或 *.example.com 通配形式，不得包含协议、端口或路径。
        - `allow_package_managers` boolean, nullable: 是否允许包管理器联网；省略或传 null 时为 false。limited 模式声明 packages 时必须显式设为 true。
        - `allow_mcp_servers` boolean, nullable: 是否允许已配置的 MCP Server 联网；省略或传 null 时为 false。

## Response `200`

请求成功。

- ManagedEnvironment
  - `id` string, required: Environment ID。
  - `type` 'environment', required
  - `name` string, required
  - `description` string, nullable, required: 用途说明。
  - `metadata` ManagedMetadata, required: 客户端自定义元数据；省略时默认为空对象。最多 16 个键，键名长度不超过 64 字符，值必须是长度不超过 512 字符的字符串。
  - `config` ManagedEnvironmentConfigResponse, required
    - `type` 'cloud', required
    - `packages` ManagedEnvironmentPackagesResponse, required
      - `type` 'packages', required
      - `apt` string[], required
      - `cargo` string[], required
      - `gem` string[], required
      - `go` string[], required
      - `npm` string[], required
      - `pip` string[], required
    - `networking` union, required
      - object
        - `type` 'unrestricted', required
      - object
        - `type` 'limited', required
        - `allowed_hosts` string[], required
        - `allow_package_managers` boolean, required
        - `allow_mcp_servers` boolean, required
  - `scope` 'organization', required
  - `state` 'active' | 'archived', required
  - `archived_at` string, nullable, required: 归档时间。
  - `created_at` string, date-time, required: 创建时间。
  - `updated_at` string, date-time, required: 更新时间。

## Other responses

- `default`: 请求失败。

## Changes

- **2026-11-03** `7fd61aa7f811`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/bigmodel/apis/zhipu-ai-api/changes/agent/managed/v1/environments/:environmentId/post.md)

---

[API](https://skmtc.dev/bigmodel/apis/zhipu-ai-api.md) - [All operations](https://skmtc.dev/bigmodel/apis/zhipu-ai-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bigmodel/apis/zhipu-ai-api/revisions/f2be7c0fcbb9?raw)
