1 つの組織を作成
MongoDB Cloud に組織を 1 件作成し、それをリクエスト元のサービス アカウントまたは API キーの組織にリンクさせます。このリソースを使用するには、リクエスト元のサービス アカウントまたは API キーに組織オーナーのロールが必要です。リクエスト元のサービス アカウントまたは API キーの組織は、支払い組織である必要があります。詳細については、MongoDB Atlas ドキュメントの「支払い組織の構成」を参照してください。
クエリ パラメータ
-
アプリケーションがレスポンスを
envelope
JSON オブジェクトにラップするかどうかを示すフラグ。一部の API クライアントは、HTTP レスポンス ヘッダーまたはステータス コードにアクセスできません。これを修正するには、クエリで envelope=true を設定します。結果のリストを返すエンドポイントは、結果オブジェクトをエンベロープとして使用します。アプリケーションは、レスポンス本体にステータス パラメータを追加します。デフォルト値は
false
です。 -
レスポンス本体を pretty-print 形式にするかどうかを示すフラグ。
デフォルト値は
false
です。Prettyprint
body
必須
作成したい組織。
-
Atlas がこの組織に対して作成する 組織サービス アカウント 。省略した場合、Atlas はこの組織の組織サービスアカウントを作成しません。指定されている場合、このオブジェクトにはすべてのボディ パラメータが必要です。同じリクエストではAPIキーを指定できないことに注意してください。
-
新しい組織からリンクされるフェデレーションを識別する、ユニークな 24 桁の 16 進数の文字列。指定する場合、新しい組織の組織オーナー候補には、フェデレーションに関連づけられた組織での所有者ロールが必要です。
形式は次のパターンと一致する必要があります:
^([a-f0-9]{24})$
。 -
組織を識別する、人間が判読可能なラベル。
形式は次のパターンと一致する必要があります:
^[\p{L}\p{N}\-_.(),:&@+']{1,64}$
。 -
組織所有者ロールを割り当てる MongoDB クラウド ユーザーを識別する、ユニークな 24 桁の 16 進数文字列。このユーザーは、呼び出し元の API キーと同じ組織のメンバーである必要があります。ただし
federationSettingsId
を指定した場合は、このユーザーには指定されたフェデレーション内の組織についての所有者ロールが必要です。このパラメータは、Programmatic API Keysで認証する場合にのみ必要です。形式は次のパターンと一致する必要があります:
^([a-f0-9]{24})$
。 -
Atlas がこの組織に対して作成する 組織サービス アカウント 。省略した場合、Atlas はこの組織の組織サービスアカウントを作成しません。指定されている場合、このオブジェクトにはすべてのボディ パラメータが必要です。同じリクエストではAPIキーを指定できないことに注意してください。
-
アラートの自動作成を無効にします。 true に設定されている場合、組織レベルのアラートは自動的に作成されません。
デフォルト値は
false
です。
atlas api organizations createOrg --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.CreateOrgApiParams{}
sdkResp, httpResp, err := client.OrganizationsApi.
CreateOrgWithParams(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/orgs" \
-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/orgs" \
-d '{ <Payload> }'
{
"apiKey": {
"desc": "string",
"roles": [
"ORG_OWNER"
]
},
"federationSettingsId": "32b6e34b3d91647abb20e7b8",
"name": "string",
"orgOwnerId": "32b6e34b3d91647abb20e7b8",
"serviceAccount": {
"description": "string",
"name": "string",
"roles": [
"ORG_MEMBER"
],
"secretExpiresAfterHours": 8
},
"skipDefaultAlertsSettings": false
}
{
"apiKey": {
"desc": "string",
"id": "32b6e34b3d91647abb20e7b8",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"privateKey": "55c3bbb6-b4bb-0be1-e66d20841f3e",
"publicKey": "zmmrboas",
"roles": [
{
"groupId": "32b6e34b3d91647abb20e7b8",
"orgId": "32b6e34b3d91647abb20e7b8",
"roleName": "ORG_MEMBER"
}
]
},
"federationSettingsId": "32b6e34b3d91647abb20e7b8",
"orgOwnerId": "32b6e34b3d91647abb20e7b8",
"organization": {
"id": "32b6e34b3d91647abb20e7b8",
"isDeleted": true,
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"name": "string",
"skipDefaultAlertsSettings": false
},
"serviceAccount": {
"clientId": "mdb_sa_id_1234567890abcdef12345678",
"createdAt": "2025-05-04T09:42:00Z",
"description": "string",
"name": "string",
"roles": [
"ORG_MEMBER"
],
"secrets": [
{
"createdAt": "2025-05-04T09:42:00Z",
"expiresAt": "2025-05-04T09:42:00Z",
"id": "32b6e34b3d91647abb20e7b8",
"lastUsedAt": "2025-05-04T09:42:00Z",
"maskedSecretValue": "mdb_sa_sk_...",
"secret": "mdb_sa_sk_..."
}
]
},
"skipDefaultAlertsSettings": false
}
{
"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"
}