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

mongocli ops-manager agents apikey list

On this page

  • Syntax
  • Options
  • Output
  • Example

The agents apikey list command retrieves all agent API keys for the specified Ops Manager project.

You must have at least GROUP_READ_ONLY privileges for a project to retrieve agent API keys for that project.

mongocli ops-manager|om agents apikey|apikeys list|ls
[ --output|-o <output-format> ]
[ --profile|-P <profile-name> ]
[ --projectId <id-of-project> ]
Option
Type
Description
Required?
--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 the public and private keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.
no
--projectId
string

Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable.

no

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

Note

After creating an agent API key, subsequent requests return only the last four characters of the key in clear text. The response replaces the key's other characters with asterisks.

ID KEY DESCRIPTION CREATED AT
<agent-key-1-id> <redacted-agent-key-1> <agent-key-1-description> <timestamp>
<agent-key-2-id> <redacted-agent-key-2> <agent-key-2-description> <timestamp>

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 agent 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 om agents apikey list

The previous command prints the following to the terminal.

Note

After creating an agent API key, subsequent requests return only the last four characters of the key in clear text. The response replaces the key's other characters with asterisks.

ID KEY DESCRIPTION CREATED AT
5f1f3a04c902201990f5388a ****************************39fe Initial API Key 1595881988159
5f1f39ffc902201990f5387d ****************************8b87 Public API generated group agent api key 1595881983276

The following command retrieves agent API keys for a project using the default profile, which contains credentials and the project ID. The output is returned in JSON format.

mongocli om agents apikey list --output json

The previous command prints the following to the terminal in JSON format.

Note

After creating an agent API key, subsequent requests return only the last four characters of the key in clear text. The response replaces the key's other characters with asterisks.

[
{
"_id": "5f1f3a04c902201990f5388a",
"key": "****************************39fe",
"desc": "Initial API Key",
"createdTime": 1595881988159,
"createdUserId": "5f1f39fdc902201990f5386a",
"createdIpAddr": "127.0.0.1",
"createdBy": "PUBLIC_API"
},
{
"_id": "5f1f39ffc902201990f5387d",
"key": "****************************8b87",
"desc": "Public API generated group agent api key",
"createdTime": 1595881983276,
"createdUserId": "5f1f39fdc902201990f5386a",
"createdIpAddr": "127.0.0.1",
"createdBy": "PUBLIC_API"
}
]

Back

Upgrade Agents to Their Latest Version