跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.qoder.com/llms.txt

Use this file to discover all available pages before exploring further.

PUT /v1/environments/{environment_id} 更新指定环境的属性(如名称、描述、配置等)。

请求头

头部必选说明
AuthorizationBearer <PAT>
Content-Typeapplication/json

路径参数

参数类型必选说明
environment_idstring环境的唯一标识(前缀为 env_

请求体

仅需传入要更新的字段,未传入的字段保持不变。
字段类型必选说明
namestring新的环境名称
descriptionstring新的环境描述
configobject新的环境配置
config.typestring是(若传 config固定值 "cloud"
config.networkingobject网络访问配置
config.networking.typestring网络类型:"unrestricted""limited""allowlist"
config.networking.allowed_hostsarray允许访问的主机列表
config.networking.allow_package_managersboolean是否允许包管理器联网
config.packagesobject预装软件包配置
config.packages.aptarrayapt 包列表
config.packages.piparraypip 包列表
config.packages.npmarraynpm 包列表
metadataobject自定义元数据键值对

示例请求

curl -s -X PUT "https://openapi.qoder.sh/api/v1/cloud/environments/env_019e3bb39b6774d8878cd0b9d237574b" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "用于 API 文档测试的环境"
  }'

示例响应

HTTP 200 OK
{
  "id": "env_019e3bb39b6774d8878cd0b9d237574b",
  "type": "environment",
  "name": "doc-test-env",
  "description": "用于 API 文档测试的环境",
  "status": "ready",
  "config": {
    "type": "cloud",
    "networking": {
      "type": "limited"
    },
    "packages": {
      "apt": ["curl"]
    }
  },
  "created_at": "2026-05-18T15:28:07.017808Z",
  "updated_at": "2026-05-18T15:28:08.093156Z"
}

响应字段

字段类型说明
idstring环境唯一标识
typestring资源类型,固定值 "environment"
namestring环境名称
descriptionstring更新后的描述
statusstring环境状态
configobject环境配置
created_atstring创建时间(ISO 8601 格式)
updated_atstring最后更新时间(已更新为最新时间)

错误码

HTTPtype说明
400invalid_request_error请求参数无效
401authentication_error认证失败,PAT 无效或过期
403permission_error无权访问此资源
404not_found_error指定 ID 的环境不存在