Navigation

mongocli iam organization apikey assign

The iam organization apikey assign command updates the description or roles of the specified organization API key.

mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys assign|update <api-key-id>
[ --desc "<description-of-key>" ]
[ --orgId <organization-id> ]
[ --output|-o <output-format> ]
[ --profile|-P <profile-name> ]
[ --role <list-of-roles> ]
Note

Use -h or --help to view the command-line help for this command.

Argument
Type
Description
Required?
<api-key-id>
string
Unique identifier for this organization API key.
yes
Option
Type
Description
Required?
--desc
string
Description of the API key to update.
no
--orgId
string

Unique identifier of the organization of the API key you want to update.

If specified, this value overrides any organization ID stored in your profile or environment variable.

If omitted, your profile must contain the organization ID.

no
--output, -o
string

Command output format. Valid values are:

  • json for output in JSON format
  • go-template for custom output using the Go template
  • go-template-file for custom output specified using the Go template file

If omitted, the command returns output in the default format.

no
--profile, -P
string

Name of the profile where your credentials are saved.

If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.

no
--role
string
Role or roles to assign to the API key. To assign more than one role, you can specify each role with a --role flag or specify the roles in a comma-separated list with one --role flag.
no

If the command succeeds, it returns the following output in the default format. If the command returns errors, see Troubleshooting for recommended solutions.

API Key '<api-key-id>' successfully updated.

The default output is a subset of the fields returned by this command. For the complete list of JSON fields returned by the command, see the Public API reference for your MongoDB service:

The following command updates the description and role of an organization API key using the default profile, which contains credentials and the organization ID. The output is returned in the default format.

mongocli iam org apikey assign 5f3d8790c9022019903c1234 --role ORG_MEMBER --desc "User1 Member Key"

The previous command prints the following to the terminal.

API Key '5f3d8790c9022019903c1234' successfully updated.
Give Feedback