创建一个项目
创建一个项目。项目将集群分组为支持应用程序环境、工作负载或两者的逻辑集合。每个项目可以具有自己的用户、团队、安全、标签和警报设置。要使用此资源,请求的服务账户或 API 密钥必须具有“读写”角色。
查询参数
-
指示应用程序是否将响应包装在
envelope
JSON 对象中的标志。某些 API 客户端无法访问 HTTP 响应标头或状态代码。要修复此问题,请在查询中设置 Envelope=true。返回结果列表的端点将结果对象用作 envelope。应用程序将状态参数添加到响应正文中。默认值为
false
。 -
指示响应正文是否应采用 prettyprint 格式的标记。
默认值为
false
。Prettyprint -
唯一的 24 位十六进制数字字符串,用于标识要向其授予指定项目的“项目所有者”角色的 MongoDB Cloud 用户。如果设置此参数,它会覆盖最早的组织所有者的默认值。
格式应符合以下模式:
^([a-f0-9]{24})$
。
body
必需
创建一个项目。
-
人类可读标签,用于标识 MongoDB Cloud 组织中包含的项目。
格式应符合以下模式:
^[\p{L}\p{N}\-_.(),:&@+']{1,64}$
。 -
唯一的 24 位十六进制数字字符串,用于标识项目所属的 MongoDB Cloud 组织。
格式应符合以下模式:
^([a-f0-9]{24})$
。 -
仅适用于 Atlas for Government。
在 Commercial Atlas 中,此字段将在请求中被拒绝,并且在响应中会缺失。
此字段对项目中的可用区域设置限制。
COMMERCIAL_FEDRAMP_REGIONS_ONLY
:仅允许在 FedRAMP Moderate 区域中部署。GOV_REGIONS_ONLY
:仅允许在 GovCloud 区域中部署。值为
COMMERCIAL_FEDRAMP_REGIONS_ONLY
或GOV_REGIONS_ONLY
。默认值为COMMERCIAL_FEDRAMP_REGIONS_ONLY
。外部文档 -
指示是否使用默认警报设置创建项目的标志。创建项目后无法更新此设置。
默认值为
true
。
atlas api projects createGroup --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20230101001/admin"
)
func main() {
ctx := context.Background()
clientID := os.Getenv("MONGODB_ATLAS_CLIENT_ID")
clientSecret := os.Getenv("MONGODB_ATLAS_CLIENT_SECRET")
// See https://dochub.mongodb.org/core/atlas-go-sdk-oauth
client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))
if err != nil {
log.Fatalf("Error: %v", err)
}
params = &sdk.CreateGroupApiParams{}
sdkResp, httpResp, err := client.ProjectsApi.
CreateGroupWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2023-01-01+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/groups" \
-d '{ <Payload> }'
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2023-01-01+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/groups" \
-d '{ <Payload> }'
{
"name": "string",
"orgId": "32b6e34b3d91647abb20e7b8",
"regionUsageRestrictions": "COMMERCIAL_FEDRAMP_REGIONS_ONLY",
"tags": [
{
"key": "string",
"value": "string"
}
],
"withDefaultAlertsSettings": true
}
{
"clusterCount": 42,
"created": "2025-05-04T09:42:00Z",
"id": "32b6e34b3d91647abb20e7b8",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"name": "string",
"orgId": "32b6e34b3d91647abb20e7b8",
"regionUsageRestrictions": "COMMERCIAL_FEDRAMP_REGIONS_ONLY",
"tags": [
{
"key": "string",
"value": "string"
}
],
"withDefaultAlertsSettings": true
}
{
"error": 400,
"detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
"reason": "Bad Request",
"errorCode": "VALIDATION_ERROR"
}
{
"error": 401,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Unauthorized",
"errorCode": "NOT_ORG_GROUP_CREATOR"
}
{
"error": 403,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Forbidden",
"errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
{
"error": 404,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
"reason": "Not Found",
"errorCode": "RESOURCE_NOT_FOUND"
}
{
"error": 409,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot delete organization link while there is active migration in following project ids: 60c4fd418ebe251047c50554",
"reason": "Conflict",
"errorCode": "CANNOT_DELETE_ORG_ACTIVE_LIVE_MIGRATION_ATLAS_ORG_LINK"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}