Docs Menu
Docs Home
/ /
MongoDB Command Line Interface
/ / /

mongocli iam globalApiKey list

On this page

  • Syntax
  • Options
  • Output
  • Examples

The iam globalApiKey list command lists the API keys for the specified organization. You can also retrieve the keys using the Ops Manager API.

mongocli iam globalApiKey|globalApiKeys list|ls
[ --limit <items-per-page> ]
[ --output|-o <output-format> ]
[ --page <page-num> ]
[ --profile|-P <profile-name> ]

Note

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

Option
Type
Description
Required?
--limit
integer
Number of items per page, up to a maximum of 500. Defaults to 100 if not specified.
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 Go template file

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

no
--page
integer
Page number (1-based). Defaults to 1 if not specified.
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.

You must have credentials with the Global Read Only role to retrieve list of Global API Keys.

no

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

ID DESCRIPTION PUBLIC KEY PRIVATE KEY
<key-id-1> <key-description-1> <public-key-1> <private-key-1>
<key-id-2> <key-description-2> <public-key-2> <private-key-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 API reference.

The following command retrieves the API keys for an Ops Manager instance using the default profile, which contains the credentials for accessing the instance. The output is returned in the default format.

mongocli iam globalApiKey list

The previous command prints the following to the terminal.

ID DESCRIPTION PUBLIC KEY PRIVATE KEY
5e3b8aa3c1234019903c9fce Global owner key abcdefgh ********-****-****-abb41202bb7c
5e7cb26fc567801990298a2a My Global API key ijklmnop ********-****-****-f4d64595457e

The following command retrieves the API keys for an Ops Manager instance using the myOM profile, which contains the credentials for accessing the instance. The output is returned in JSON format.

mongocli iam globalApiKey list --orgId 5a1b39eec902201990f12345 -P myOM --output json

The previous command retrieves the API keys for an organization and prints the following to the terminal in JSON format.

[
{
"id": "5e3b8aa3c1234019903c9fce",
"desc": "Global owner key",
"roles": [
{
"roleName": "GLOBAL_OWNER"
}
],
"privateKey": "********-****-****-123468e0b5be",
"publicKey": "abcdefgh"
},
{
"id": "5e7cb26fc567801990298a2a",
"desc": "My Global API key",
"roles": [
{
"roleName": "GLOBAL_READ_ONLY"
},
{
"roleName": "GLOBAL_USER_ADMIN"
}
],
"privateKey": "********-****-****-322d7d5e1234",
"publicKey": "ijklmnop"
}
]

Back

Create a Global API Key