mongocli iam project apikey list
The iam project apikey list
command lists the
API keys for the specified project.
You must have GROUP_USER_ADMIN
privileges to list
API keys for the project.
Syntax
mongocli iam project|projects apiKey|apiKeys|apikeys list|ls [ --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.
Options
Option | Type | Description | Required? |
---|---|---|---|
--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.
ID PUBLIC KEY DESCRIPTION <key-id-1> <public-key-1> <key-description-1> <key-id-2> <public-key-2> <key-description-2>
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:
Examples
The following command retrieves the API keys for a project using the default profile, which contains credentials and the project ID. The output is returned in the default format.
mongocli iam project apikey list
The previous command prints the following to the terminal.
ID PUBLIC KEY DESCRIPTION 5f4578684b4afb5e8cd44ee9 mkoztppy Project Owner 5f469ea0f2c5937c5cdb1081 hdlvegpx External Read-Only
The following command retrieves the API keys for a
project using the myOM
profile, which contains
credentials and specifies the Ops Manager service. The output is
returned in JSON format.
mongocli iam project apikey list --projectId 5e399b9a7a3e5a1772948493 --profile myOM --output json
The previous command retrieves the API keys for a project and prints the following to the terminal in JSON format.
[ { "id": "5f4578684b4afb5e8cd44ee9", "desc": "Project Owner", "roles": [ { "groupId": "5e399b9a7a3e5a1772948493", "roleName": "GROUP_OWNER" }, { "orgId": "5dd6fa0c7a3e5a1d0fa27e35", "roleName": "ORG_MEMBER" } ], "privateKey": "********-****-****-1676fa25614f", "publicKey": "mkoztppy" }, { "id": "5f469ea0f2c5937c5cdb1081", "desc": "External Read-Only", "roles": [ { "orgId": "5dd6fa0c7a3e5a1d0fa27e35", "roleName": "ORG_MEMBER" }, { "groupId": "5e399b9a7a3e5a1772948493", "roleName": "GROUP_READ_ONLY" } ], "privateKey": "********-****-****-a6568963a711", "publicKey": "hdlvegpx" } ]