> This page location: /docs.md > /docs/tools-and-connectors.md > /docs/atlas/cli/current.md > /docs/atlas/cli/current/connect-atlas-cli.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

<!--
Tab options on this page. Append to the .md URL to filter:
  ?tabs=<id,...>   select specific tabs (e.g. ?tabs=nodejs,shell)
  ?allTabs=true    include every tab
  (no param)       default: one tab per tabset

Available tabs:
  platforms: windows, macos, linux
  other tabs: Default, Named
-->

# Save Connection Settings

You can save your frequently-used connection settings as profiles. Profiles store the project IDs, organization IDs, and, optionally, API (Application Programming Interface) 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](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-save-connection-settings.md#std-label-config-toml-location) called `config.toml`.

**Note:**

Any settings stored in [environment variables](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-env-variables.md#std-label-atlas-cli-env-vars) 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:

### Windows

```text
%AppData/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 |
| --- | --- | --- |
| `UserAccount` | Atlas login credentials and an authentication token | Best for non-programmatic use |
| `ServiceAccount` | Service Account | Best for programmatic use with a Service Account |
| `APIKeys` | API (Application Programming Interface) keys | Best for programmatic use with an API Key |

To learn more, see [Select a Connection Method.](https://www.mongodb.com/docs/atlas/cli/current/connect-atlas-cli.md#std-label-connect-atlas-cli)

### Complete the Prerequisites

- [Install the Atlas CLI.](https://www.mongodb.com/docs/atlas/cli/current/install-atlas-cli.md#std-label-install-atlas-cli)

- Add your host's IP address to the [IP access list.](https://www.mongodb.com/docs/atlas/security/ip-access-list.md#std-label-access-list)

- If you select `atlas config init` as your connection method, you must [Configure API keys.](https://www.mongodb.com/docs/atlas/configure-api-access.md#std-label-atlas-admin-api-access)

- If your Atlas CLI installation is behind a firewall and you want to use a proxy URL (Uniform Resource Locator), set up the `HTTP_PROXY` or `HTTPS_PROXY` [environment variable.](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-env-variables.md#std-label-atlas-cli-env-vars)

  **Important:**

  Atlas CLI supports `http`, `https`, and `socks5` schemes. You must specify `cloud.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.](https://en.wikipedia.org/wiki/Proxy_server)

### Follow These Steps

Select a use case and follow the procedure to create a profile.

#### Non-programmatic Use

Select the default profile or a named profile.

Create a default profile to:

- Run a command without specifying a profile, environment variables, or `--projectId` and `--orgId` flags.

- Use the `--profile default` flag.

Create a named profile to use the `--profile <profileName>` flag.

### Default Profile

Follow these steps to create the default profile. If the default profile already exists, these commands update the default profile's values.

1. Run the authentication command.

   Run the `atlas auth login` command in your terminal.

   ```sh
   atlas auth login
   ```

   The command opens a browser window and returns a one-time activation code. This code expires after 10 minutes.

2. Sign into Atlas.

   If you aren't signed in already, sign into your Atlas account in the browser.

3. Enter the authorization code.

   Paste your activation code into the browser and click Confirm Authorization.

4. Return to the Atlas CLI.

   Return to the terminal. If you connect successfully, you see a message:

   `Successfully logged in as {Your Email Address}.`

5. Select your default organization.

   Press the Down Arrow and Up Arrow keys to highlight the desired organization and press Enter.

   ```sh
   ? Choose a default organization:  [Use arrows to move, type to filter]
   > Org1 (5e39bf1212121e685774c81c)
   ```

   **Note:**

   If you have access to more than 500 organizations, you must type the organization ID or the organization name to filter the results before you use the arrows to select an organization.

6. Select your default project.

   Press the Down Arrow and Up Arrow keys to highlight the desired project and press Enter.

   ```sh
   ? Choose a default project:  [Use arrows to move, type to filter]
   Project1 (5e5ebffd0c04a97009061234)
   Project2 (5cfacee6014b761b07f15678)
   > Project3 (5e39bf4979358e6857741212)
   Project4 (5c815cc7014b768fb67e3434)
   ```

7. Select your default output format.

   Press the Down Arrow and Up Arrow keys to highlight the desired output format and press Enter.

   ```sh
   ? Default Output Format:  [Use arrows to move, type to filter]
   > plaintext
   json
   ```

   | 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. |

8. Specify the path to the MongoDB Shell, [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh), on your system.

   The Atlas CLI uses the specified [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) path so that you can access your deployments. The default value is `/usr/local/bin/mongosh`. Press Enter to accept the default or specify the path to [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) on your system and press Enter.

   ```sh
   ? Default MongoDB Shell Path: [? for help] (/usr/local/bin/mongosh)
   ```

9. Verify your profile settings.

   View the configuration file or run the `atlas config describe` command to verify your profile. For the default profile, the `<profileName>` is `default`.

   ```sh
   atlas config describe <profileName>
   ```

   The command returns following settings. The Atlas CLI redacts the access token and refresh token values for security.

   ```sh
   SETTING           VALUE
   "access_token":   "redacted",
   "mongosh_path":   "/usr/local/bin/mongosh",
   "org_id":         "60c9877baf349d6fc4fd9744",
   "output":         "json",
   "project_id":     "60c94857241ae99848af45ad",
   "refresh_token":  "redacted",
   "service":        "cloud"
   ```

#### Programmatic Use

Select the default profile or a named profile.

Create a default profile to:

- Run a command without specifying a profile, environment variables, or `--projectId` and `--orgId` flags.

- Use the `--profile default` flag.

Create a named profile to use the `--profile <profileName>` flag.

### Default Profile

Follow these steps to create the default profile. If the default profile already exists, these commands update the default profile's values.

1. Run the authentication command.

   Run the `atlas config init` command in your terminal.

   ```sh
   atlas config init
   ```

2. Enter your API (Application Programming Interface) keys.

   Enter your public and private keys when prompted.

3. Select your default organization.

   Press the Down Arrow and Up Arrow keys to highlight the desired organization and press Enter.

   ```sh
   ? Choose a default organization:  [Use arrows to move, type to filter]
   > Org1 (5e39bf1212121e685774c81c)
   ```

4. Select your default project.

   Press the Down Arrow and Up Arrow keys to highlight the desired project and press Enter.

   ```sh
   ? Choose a default project:  [Use arrows to move, type to filter]
   Project1 (5e5ebffd0c04a97009061234)
   Project2 (5cfacee6014b761b07f15678)
   > Project3 (5e39bf4979358e6857741212)
   Project4 (5c815cc7014b768fb67e3434)
   ```

5. Select your default output format.

   Press the Down Arrow and Up Arrow keys to highlight the desired output format and press Enter.

   ```sh
   ? Default Output Format:  [Use arrows to move, type to filter]
   > plaintext
   json
   ```

   | 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. |

6. Specify the path to the MongoDB Shell, [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh), on your system.

   The Atlas CLI uses the specified [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) path so that you can access your deployments. The default value is `/usr/local/bin/mongosh`. Press Enter to accept the default or specify the path to [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) on your system and press Enter.

   ```sh
   ? Default MongoDB Shell Path: [? for help] (/usr/local/bin/mongosh)
   ```

7. Verify your profile settings.

   View the configuration file or run the `atlas config describe` command to verify your profile. For the default profile, the `<profileName>` is `default`.

   ```sh
   atlas config describe <profileName>
   ```

   The command returns following settings. The Atlas CLI redacts the API (Application Programming Interface) key values for security.

   ```sh
   SETTING            VALUE
   "mongosh_path":    "/usr/local/bin/mongosh",
   "org_id":          "60c9877baf349d6fc4fd9744",
   "output":          "json",
   "private_api_key": "redacted",
   "project_id":      "60c94857241ae99848af45ad",
   "public_api_key":  "redacted",
   "service":         "cloud"
   ```

## Update a Profile

You can update the settings stored in your configuration file in the following ways:

- Edit the `config.toml` file with a text editor.

- Run the `atlas config set` command for a setting. This edits an individual value in the `config.toml` file.

## Run a Command with a Profile

To run an Atlas CLI command using a profile:

- [Create a Profile.](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-save-connection-settings.md#std-label-atlas-cli-set-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`:

```text
atlas <command> --profile myProfile
```

This command uses the default profile:

```text
atlas <command>
```
