You can save your frequently-used connection settings as profiles. Profiles store the project IDs, organization IDs, and, optionally, API keys to use in future Atlas CLI sessions. To save time, you can specify a profile instead of using the --projectId and --orgId flags with each command. The Atlas CLI stores your profiles in a configuration file called config.toml.
Note
Any settings stored in environment variables take precedence over settings stored in profiles. Any project or organization specified with the --projectId and --orgId flags take precedence over both the profile and the environment variables.
Locate the Configuration File
The Atlas CLI saves the configuration file to the following location depending on your operating system:
/Users/{username}/Library/Application Support/atlascli .. tab:: :tabid: windows .. code-block:: %AppData%\atlascli .. tab:: :tabid: linux .. code-block:: $XDG_CONFIG_HOME/atlascli By default, Atlas CLI saves the configuration file in the path defined in the ``$XDG_CONFIG_HOME`` environment variable. You can modify the path defined in the ``$XDG_CONFIG_HOME`` variable to your preferred location. To learn more about modifying the ``$XDG_CONFIG_HOME`` variable, see `XDG Base Directory Specification <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html>`__. If ``$XDG_CONFIG_HOME`` is not set, the Atlas CLI uses: .. code-block:: $HOME/.config/atlascli
The Atlas CLI grants the user who ran the command read and write access to the file.
Create a Profile
The first time you run the atlas auth login or atlas config init command, the Atlas CLI automatically creates the config.toml file and a default profile. If you run a command without specifying a profile, environment variables, or --projectId and --orgId flags, the Atlas CLI uses the default profile for the command.
Select Your Use Case
Select a connection method based on your use case:
Option | Authentication Method | Use Case |
|---|---|---|
| Atlas login credentials and an authentication token | Best for non-programmatic use |
| Service Account | Best for programmatic use with a Service Account |
| API keys | Best for programmatic use with an API Key |
To learn more, see Select a Connection Method.
Complete the Prerequisites
Add your host's IP address to the IP access list.
If you select
atlas config initas your connection method, you must Configure API keys.If your Atlas CLI installation is behind a firewall and you want to use a proxy URL, set up the
HTTP_PROXYorHTTPS_PROXYenvironment variable.Important
Atlas CLI supports
http,https, andsocks5schemes. You must specifycloud.mongodb.com/as the main target URL in the proxy service's access list. You must also specify the username and password if your proxy configuration enables authentication.To learn more, see Proxy server.
Follow These Steps
Select a use case and follow the procedure to create a profile.
Select the default profile or a named profile.
Create a default profile to:
Run a command without specifying a profile, environment variables, or
--projectIdand--orgIdflags.Use the
--profile defaultflag.
Create a named profile to use the --profile <profileName> flag.
Follow these steps to create the default profile. If the default profile already exists, these commands update the default profile's values.
atlas auth login The command opens a browser window and returns a one-time activation code. This code expires after 10 minutes.
? Choose a default organization: [Use arrows to move, type to filter] Org1 (5e39bf1212121e685774c81c) .. include:: /includes/fact-more-than-500-orgs.rst
? Choose a default project: [Use arrows to move, type to filter] Project1 (5e5ebffd0c04a97009061234) Project2 (5cfacee6014b761b07f15678) Project3 (5e39bf4979358e6857741212) Project4 (5c815cc7014b768fb67e3434)
? Default Output Format: [Use arrows to move, type to filter] plaintext json .. list-table:: :header-rows: 1 :widths: 30 70 * - Option - Description * - ``plaintext`` - Human-readable output that includes all fields that the Atlas CLI returns. * - ``json`` - JSON output that includes all fields that MongoDB CLI returns.
? Default MongoDB Shell Path: [? for help] (/usr/local/bin/mongosh)
atlas config describe <profileName> The command returns following settings. The Atlas CLI redacts the access token and refresh token values for security. .. code-block:: sh :copyable: false SETTING VALUE "access_token": "redacted", "mongosh_path": "/usr/local/bin/mongosh", "org_id": "60c9877baf349d6fc4fd9744", "output": "json", "project_id": "60c94857241ae99848af45ad", "refresh_token": "redacted", "service": "cloud"
atlas auth login --profile myProfile The command opens a browser window and returns a one-time activation code. This code expires after 10 minutes. .. include:: /includes/steps-atlas-cli-add-profile-nonprogrammatic.rst .. tab:: Programmatic Use :tabid: atlas-config-init .. include:: /includes/fact-default-vs-named-profile.rst .. tabs:: .. tab:: Default Profile :tabid: Default Follow these steps to create the default profile. If the default profile already exists, these commands update the default profile's values. .. procedure:: :style: normal .. include:: /includes/steps-atlas-cli-auth-prog-default.rst .. include:: /includes/steps-atlas-cli-add-profile-programmatic.rst .. tab:: Named Profile :tabid: Named Follow these steps to create a profile with a custom name. .. procedure:: :style: normal .. step:: Run the authentication command. Run the ``atlas config init`` command in your terminal with the ``profile <profileName>`` flag. ``<profileName>`` should be the desired name for your new profile. .. code-block:: sh atlas config init --profile myProfile .. include:: /includes/steps-atlas-cli-add-profile-programmatic.rst
Update a Profile
You can update the settings stored in your configuration file in the following ways:
Edit the
config.tomlfile with a text editor.Run the
atlas config setcommand for a setting. This edits an individual value in theconfig.tomlfile.
Run a Command with a Profile
To run an Atlas CLI command using a profile:
Append the
--profile <profileName>flag to a command or omit the--profile <profileName>flag to use the default profile.
Example
This command uses a profile named myProfile:
atlas <command> --profile myProfile This command uses the default profile: .. code-block:: atlas <command>