mongocli iam organizations apiKeys assign
Modify the roles or description for the specified organization API key.
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 apiKeyId argument, run mongocli iam organizations apiKeys list.
To use this command, you must authenticate with a user account or an API key with the Organization User Admin role.
Syntax
Command Syntax
mongocli iam organizations apiKeys assign <apiKeyId> [options]
Arguments
Name | Type | Required | Description |
---|---|---|---|
apiKeyId | string | true | Unique 24-digit string that identifies your API key. |
Options
Name | Type | Required | Description |
---|---|---|---|
--desc | string | false | Description of the API key. |
-h, --help | false | help for assign | |
--orgId | string | false | Organization ID to use. This option overrides the settings in the configuration file or environment variable. |
-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. |
--role | strings | false | 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/createApiKey/. Passing this flag replaces preexisting data. |
Inherited Options
Name | Type | Required | Description |
---|---|---|---|
-P, --profile | string | false | Name of the profile to use from your configuration file. To learn about profiles for MongoCLI, see https://dochub.mongodb.org/core/atlas-cli-configuration-file. |
Output
If the command succeeds, the CLI returns output similar to the following sample. Values in brackets represent your values.
API Key '<ID>' successfully updated.
Examples
# Modify the role and description for the API key with the ID 5f24084d8dbffa3ad3f21234 for the organization with the ID 5a1b39eec902201990f12345: mongocli iam organizations apiKeys assign 5f24084d8dbffa3ad3f21234 --role ORG_MEMBER --desc "User1 Member Key" --orgId 5a1b39eec902201990f12345 --output json