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

mongocli iam organization apikey list

On this page

  • Syntax
  • Options
  • Output
  • Examples

The iam organization apikey list command lists the API keys for the specified organization.

mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys list|ls
[ --orgId <organization-id> ]
[ --output|-o <output-format> ]
[ --profile|-P <profile-name> ]

Note

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

Option
Type
Description
Required?
--orgId
string

Unique identifier of the organization whose API keys you want to list.

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 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

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 Public API reference for your MongoDB service:

The following command retrieves the API keys for an organization using the default profile, which contains credentials and the organization ID. The output is returned in the default format.

mongocli iam organization apikey list

The previous command prints the following to the terminal.

ID DESCRIPTION PUBLIC KEY PRIVATE KEY
5e3b8aa3c1234019903c9fce User1 Key abcdefgh ********-****-****-123468e0b5be
5e7cb26fc567801990298a2a User2 Key ijklmnop ********-****-****-322d7d5e1234

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

mongocli iam organization apikey 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": "User1 Key",
"roles": [
{
"orgId": "5e429f2e12345c6eac4d59c9",
"roleName": "ORG_OWNER"
}
],
"privateKey": "********-****-****-123468e0b5be",
"publicKey": "abcdefgh"
},
{
"id": "5e7cb26fc567801990298a2a",
"desc": "User2 Key",
"roles": [
{
"orgId": "5e4e593f70dfbf1212343436",
"roleName": "ORG_MEMBER"
}
],
"privateKey": "********-****-****-322d7d5e1234",
"publicKey": "ijklmnop"
}
]

Back

Create an Organization API Key