mongocli iam globalApiKey create
The iam globalApiKey create
command creates a new Global
API Key for the specified Ops Manager
instance. You must have the
Global Owner role
to create a Global API key. You can also create the key through
the Ops Manager
UI and
API.
Syntax
mongocli iam globalApiKey|globalApiKeys create --desc "<description-of-key>" [ --output|-o <output-format> ] [ --profile|-P <profile-name> ] --role <list-of-roles>
Note
Use -h
or --help
to view the command-line help for
this command.
Options
Option | Type | Description | Required? | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
--desc | string | Description of the API key. This description can’t be longer
than 250 characters. | yes | ||||||||||||||
--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. You must have credentials with the | no | ||||||||||||||
--role | string | Role or roles to assign to the API key. To assign more than
one role, you can specify each role with a
| yes |
Output
If the command succeeds, it prints the following output to the terminal. If the command returns errors, see Troubleshooting for recommended solutions.
API Key '<api-key-id>' created. Public API Key <public-key> Private API Key <private-key>
Warning
Copy and Save Public and Private Keys
MongoDB CLI returns the Private API Key only once. After running this command, immediately copy, save, and secure both the Public and Private API Keys.
For the complete list of JSON fields returned by the command, see the public API reference. The default output contains only a subset of the fields returned by this command.
Examples
The following command creates a Global API Key using a profile
named om-admin
, which contains the Organization Owner
credentials, the organization ID, and specifies the Ops Manager
service. The output is returned in the default format.
mongocli iam globalApiKey create --desc "My Global API key" --role "GLOBAL_READ_ONLY","GLOBAL_USER_ADMIN" --profile om-admin
The previous command creates the API key and prints the following to the terminal.
API Key '5f3d8790c12345678903c8d66' created. Public API Key abcdefgh Private API Key b4d12345-b4a3-1234-b24e-729b3f35642d
The following command creates a Global API Key using a profile
named om-admin
, which contains the Organization Owner
credentials, the organization ID, and specifies the Ops Manager
service. The output is returned in JSON format.
mongocli iam globalApiKey create --desc "My Global API key" --role "GLOBAL_READ_ONLY","GLOBAL_USER_ADMIN" --profile om-admin --output json
The previous command creates the API key and prints the following to the terminal in JSON format.
{ "id": "5f3d8ea3c9022019903c9fce", "desc": "My Global API key", "roles": [ { "roleName": "GLOBAL_READ_ONLY" }, { "roleName": "GLOBAL_USER_ADMIN" } ], "privateKey": "b4d12345-b4a3-1234-b24e-729b3f35642d", "publicKey": "abcdefgh" }