创建环境
更新时间:2026-11-13
POST
https://api.dumate.cn/api/dma/v1/environments
本接口用于创建环境(Environment),定义会话运行的沙箱,包括预装软件包。
创建成功后返回环境对象,其中 id 为环境标识,创建会话时使用。
权限说明
使用 API Key 鉴权调用 API 流程,具体调用流程,请查看认证鉴权。
请求参数
Headers 参数
除公共头域外,无其它特殊头域
Body 参数
name
string
环境名称。
长度:1–256 个字符。
必选
config
object {2}
环境配置。
不传时默认创建 type 为 cloud 的环境。
可选
显示子属性
隐藏子属性
type
string
环境类型。
可选值:cloud(托管云沙箱)
必选
packages
object {2}
预装软件包,按包管理器分组,值为包名数组。
仅 type 为 cloud 时使用。
可选
显示子属性
隐藏子属性
npm
array
通过 npm 预装的包名列表。
可选
显示子属性
隐藏子属性
items
string
pip
array
通过 pip 预装的包名列表。
可选
显示子属性
隐藏子属性
items
string
description
string
环境描述。
长度:不超过 1024 个字符。
可选
metadata
object
自定义键值,最多 16 对。
可选
显示子属性
隐藏子属性
请求结构
POST /api/dma/v1/environments HTTP/1.1
Host: api.dumate.cn
Authorization: Bearer <YOUR_API_KEY>
Content-Type: application/json
示例代码
请求示例
curl --location --request POST "https://api.dumate.cn/api/dma/v1/environments" \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"name": "doc-test-env-1109",
"config": {
"type": "cloud",
"packages": {
"pip": [
"pandas"
]
}
}
}'
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
type
string
资源类型标识,固定为 environment。
可选
id
string
环境标识,env_ 前缀。
可选
name
string
环境名称。
可选
description
string
环境描述;未设置时为 null。
可选
config
object {2}
环境配置。
可选
显示子属性
隐藏子属性
type
string
环境类型。
可选值:cloud(托管云沙箱)
可选
packages
object {7}
预装软件包,按包管理器分组;未设置的包管理器返回空数组。
可选
显示子属性
隐藏子属性
type
string
子对象类型标识,固定为 packages。
可选
apt
array
通过 apt 预装的包名列表;当前恒为空数组。
可选
显示子属性
隐藏子属性
items
string
cargo
array
通过 cargo 预装的包名列表;当前恒为空数组。
可选
显示子属性
隐藏子属性
items
string
gem
array
通过 gem 预装的包名列表;当前恒为空数组。
可选
显示子属性
隐藏子属性
items
string
go
array
通过 go 预装的包名列表;当前恒为空数组。
可选
显示子属性
隐藏子属性
items
string
npm
array
通过 npm 预装的包名列表;未设置时为空数组。
可选
显示子属性
隐藏子属性
items
string
pip
array
通过 pip 预装的包名列表;未设置时为空数组。
可选
显示子属性
隐藏子属性
items
string
metadata
object
自定义键值;未设置时为空对象。
可选
显示子属性
隐藏子属性
created_at
string
创建时间,RFC 3339 格式,UTC。
可选
updated_at
string
最近更新时间,RFC 3339 格式,UTC。
可选
archived_at
string
归档时间,RFC 3339 格式,UTC;未归档时为 null。
可选
响应示例
{
"type": "environment",
"id": "env_cdf80dd7ee404774",
"name": "doc-test-env-1109",
"description": null,
"config": {
"type": "cloud",
"packages": {
"type": "packages",
"apt": [],
"cargo": [],
"gem": [],
"go": [],
"npm": [],
"pip": [
"pandas"
]
}
},
"metadata": {},
"created_at": "2026-11-09T13:37:07Z",
"updated_at": "2026-11-09T13:37:07Z",
"archived_at": null
}
评价此篇文章
