mongocli iam organization apikey whitelist create

The iam organization apikey whitelist create command creates one or more new whitelist entries for the specified API key.

mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys whitelist|whitelists create
--apiKey <api-key-id>
[ --cidr <cidr-entry> ]
[ --ip <id-entry> ]
[ --orgId <organization-id> ]
[ --output|-o <output-format> ]
[ --profile|-P <profile-name> ]

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

Unique identifier of the API key.
Whitelist entry in CIDR notation to be added for the API key. To add more than one entry in CIDR notation, you can specify each entry with a --cidr flag or specify the entries in a comma-separated list with one --cidr flag.
IP address to be added to the whitelist for the API key. To add more than one IP address, you can specify each address with an --ip flag or specify the addresses in a comma-separated list with one --ip flag.

Unique identifier of the organization to which the target API key belongs.

If specified, this value overrides any organization ID stored in your profile or environment variable.

If omitted, your profile must contain the organization ID.

--output, -o

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 the Go template file

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

--profile, -P

Name of the profile where your credentials are saved.

You must have credentials with the Organization Owner role to create an API key for the organization.

If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.


If the command succeeds, it prints the following output to the terminal. If the command returns errors, see Troubleshooting for recommended solutions.

Created new whitelist entry(s).

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 a whitelist entry for 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 orgs apikey whitelist create --apiKey 5f24084d8dbffa3ad3f21234 --ip

The previous command creates the whitelist entry and prints the following to the terminal.

Created new whitelist entry(s).
Give Feedback