mongocli iam organization apikey create¶
iam organization apikey create command creates a new
API key for the specified organization.
You must have the
Organization Owner role to create an API key for
mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys create --desc "<description-of-key>" [ --orgId <organization-id> ] [ --output|-o <output-format> ] [ --profile|-P <profile-name> ] --role <list-of-roles>
--help to view the command-line help for
Description of the API key.
Role or roles to assign to the API key. To assign more than one role, you can specify each role with a
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>
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.
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 creates an API key using the
default profile, which contains
credentials, the organization ID, and specifies the Atlas
service. The output is returned in the default format.
mongocli iam organization apikey create --desc "My API key" --role ORG_OWNER
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