跳转到主要内容

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.

POST /v1/environments 创建一个新的云端执行环境,用于托管 Agent 会话。

请求头

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

请求体

字段类型必选说明
namestring环境名称,用于标识该环境
descriptionstring环境描述
configobject环境配置对象
config.typestring固定值 "cloud"
config.networkingobject网络访问配置
config.networking.typestring网络类型:"unrestricted"(无限制)、"limited"(受限)、"allowlist"(白名单)
config.networking.allowed_hostsarray允许访问的主机列表(仅 allowlist 类型需要)
config.networking.allow_package_managersboolean是否允许包管理器联网
config.packagesobject预装软件包配置
config.packages.aptarray需要预装的 apt 包列表
config.packages.piparray需要预装的 pip 包列表
config.packages.npmarray需要预装的 npm 包列表
metadataobject自定义元数据键值对

示例请求

curl -s -X POST "https://openapi.qoder.sh/api/v1/cloud/environments" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "doc-test-env",
    "config": {
      "type": "cloud",
      "networking": {
        "type": "limited"
      },
      "packages": {
        "apt": ["curl"]
      }
    }
  }'

示例响应

HTTP 201 Created
{
  "id": "env_019e3bb39b6774d8878cd0b9d237574b",
  "type": "environment",
  "name": "doc-test-env",
  "description": "",
  "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:07.017808Z"
}

响应字段

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

错误码

HTTPtype说明
400invalid_request_error请求参数无效(如缺少 config.type 字段)
401authentication_error认证失败,PAT 无效或过期
403permission_error无权执行此操作
409conflict_error同名环境已存在