Docs Menu
Docs Home
/ /
Atlas CLI
/ / /

atlas projects apiKeys assign

On this page

  • Syntax
  • Arguments
  • Options
  • Inherited Options
  • Output
  • Examples

Assign the specified organization API key to your project and modify the API key's roles for the project.

When you modify the roles for an organization API key with this command, the values you specify overwrite the existing roles assigned to the API key.

To view possible values for the ID argument, run atlas organizations apiKeys list.

Command Syntax
atlas projects apiKeys assign <ID> [options]
Name
Type
Required
Description
ID
string
true
Unique 24-digit string that identifies your API key.
Name
Type
Required
Description
-h, --help
false
help for assign
-o, --output
string
false
Output format. Valid values are json, json-path, go-template, or go-template-file. To see the full output, use the -o json option.
--projectId
string
false
Hexadecimal string that identifies the project to use. This option overrides the settings in the configuration file or environment variable.
--role
strings
true
Role or roles that you want to assign to the API key. To assign more than one role, specify each role with a separate role flag or specify all of the roles as a comma-separated list using one role flag. To learn which values the CLI accepts, see the Items Enum for roles in the Atlas API spec: https://www.mongodb.com/pt-br/docs/atlas/reference/api-resources-spec/v2/#tag/Programmatic-API-Keys/operation/createProjectApiKey/.
Name
Type
Required
Description
-P, --profile
string
false

If the command succeeds, the CLI returns output similar to the following sample. Values in brackets represent your values.

API Key successfully assigned.
# Assign an organization API key with the ID 5f46ae53d58b421fe3edc115 and grant the GROUP_DATA_ACCESS_READ_WRITE role for the project with ID 5e2211c17a3e5a48f5497de3:
atlas projects apiKeys assign 5f46ae53d58b421fe3edc115 --projectId 5e1234c17a3e5a48f5497de3 --role GROUP_DATA_ACCESS_READ_WRITE --output json

Back

apiKeys