mongocli iam project apikey delete
The iam project apikey delete
command unassigns the specified
API key from a project. The unassigned API key still exists at the
organization level and can be reassigned to a project with
mongocli iam project apikey assign
. You must confirm the operation
when you run this command without the --force
option.
You must have GROUP_USER_ADMIN
privileges to delete an
API key from the project.
Syntax
mongocli iam project|projects apiKey|apiKeys|apikeys delete|rm <api-key-id> [ --force ] [ --projectId <project-id> ] [ --output|-o <output-format> ] [ --profile|-P <profile-name> ]
Note
Use -h
or --help
to view the command-line help for
this command.
Arguments
Argument | Type | Description | Required? |
---|---|---|---|
<api-key-id> | string | Unique identifier for this project API key. | yes |
Options
Option | Type | Description | Required? |
---|---|---|---|
--force | Flag that indicates that the API key can
be deleted without requiring confirmation. | no | |
--projectId | string | Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable. | no |
--output , -o | string | Command output format. Valid values are:
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 |
Output
If the command succeeds, it returns the following output in the default format. If the command returns errors, see Troubleshooting for recommended solutions.
? Are you sure you want to delete: <api-key-id> Yes API Key '<api-key-id>' deleted
Examples
The following command deletes a project API key with confirmation. The command uses the default profile, which contains credentials and the project ID, and returns the output in the default format.
mongocli iam org apikey delete 5f46abb2d58b421fe3edbb3a
The previous command prints the following to the terminal.
? Are you sure you want to delete: 5f46abb2d58b421fe3edbb3a Yes API Key '5f46abb2d58b421fe3edbb3a' deleted
The following command deletes a project API key without
confirmation. The command uses the myOM
profile, which
contains credentials and specifies the Ops Manager service, and
returns the output in JSON format.
mongocli iam org apikey delete 5f3d8790c9022019903c1234 --force -P myOM --output json
The previous command deletes the API key without confirmation and prints the following to the terminal.
API Key '5f3d8790c9022019903c1234' deleted