Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/command/atlas-projects-apiKeys-create.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ atlas projects apiKeys create
Create an organization API key and assign it to your project.

MongoDB returns the private API key only once. After you run this command, immediately copy, save, and secure both the public and private API keys.
If you don't provide an organization level role, the API Key defaults to organization member of the project parent organization.

To use this command, you must authenticate with a user account or an API key with the Project User Admin role.
To use this command, you must authenticate with a user account or an API key with any of the following roles: Project User Admin or Organization User Admin to manage organization level roles.

Syntax
------
Expand Down Expand Up @@ -96,3 +97,10 @@ Examples

# Create an organization API key with the GROUP_OWNER role and assign it to the project with ID 5e2211c17a3e5a48f5497de3:
atlas projects apiKeys create --desc "My API key" --projectId 5e1234c17a3e5a48f5497de3 --role GROUP_OWNER --output json


.. code-block::
:copyable: false

# Create an organization API key with the GROUP_SEARCH_INDEX_EDITOR and GROUP_DATABASE_ACCESS_ADMIN roles and assign it to the project with ID 5e2211c17a3e5a48f5497de3:
atlas projects apiKeys create --desc "My API key" --projectId 5e1234c17a3e5a48f5497de3 --role GROUP_SEARCH_INDEX_EDITOR,GROUP_DATABASE_ACCESS_ADMIN --output json
8 changes: 6 additions & 2 deletions internal/cli/projects/apikeys/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,18 @@ func CreateBuilder() *cobra.Command {
Use: "create",
Short: "Create an organization API key and assign it to your project.",
Long: `MongoDB returns the private API key only once. After you run this command, immediately copy, save, and secure both the public and private API keys.
If you don't provide an organization level role, the API Key defaults to organization member of the project parent organization.

` + fmt.Sprintf(usage.RequiredRole, "Project User Admin"),
` + fmt.Sprintf(usage.RequiredOneOfRoles, "Project User Admin or Organization User Admin to manage organization level roles"),
Annotations: map[string]string{
"output": createTemplate,
},
Args: require.NoArgs,
Example: ` # Create an organization API key with the GROUP_OWNER role and assign it to the project with ID 5e2211c17a3e5a48f5497de3:
atlas projects apiKeys create --desc "My API key" --projectId 5e1234c17a3e5a48f5497de3 --role GROUP_OWNER --output json`,
atlas projects apiKeys create --desc "My API key" --projectId 5e1234c17a3e5a48f5497de3 --role GROUP_OWNER --output json

# Create an organization API key with the GROUP_SEARCH_INDEX_EDITOR and GROUP_DATABASE_ACCESS_ADMIN roles and assign it to the project with ID 5e2211c17a3e5a48f5497de3:
atlas projects apiKeys create --desc "My API key" --projectId 5e1234c17a3e5a48f5497de3 --role GROUP_SEARCH_INDEX_EDITOR,GROUP_DATABASE_ACCESS_ADMIN --output json`,
PreRunE: func(cmd *cobra.Command, _ []string) error {
return opts.PreRunE(
opts.ValidateProjectID,
Expand Down