Skip to navigation

Sign in to the Atlas CLI

Sign in with an API key, keep several profiles, check who you are, sign out, and see where the CLI stores your key.

Get an API key

Make a key in the Atlas app. Open Settings, then More settings, then API keys. You can have up to 5 keys, so make one just for the CLI. Full steps are in Authentication and API keys.

Sign in

atlas login --api-key YOUR_API_KEY

The CLI tests the key by asking Atlas for your account profile. If the key is wrong, nothing is saved, you see invalid API key with the reason, and the exit code is 3. If it works, the CLI saves a profile named default, makes it the active one and prints Logged in as profile "default".

FlagDefaultWhat it does
--api-keyATLAS_API_KEY, if setYour Atlas API key. Required if ATLAS_API_KEY isn’t set
--profiledefaultThe name to save this key under
--base-urlhttps://api.youratlas.com/v1/apiThe API address for this profile

Check who you are

atlas whoami

It prints four lines:

Profile: default
Email: <your account email>
Name: <your name>
Base URL: https://api.youratlas.com/v1/api

If the key comes from ATLAS_API_KEY, the first line says Profile: (credentials from environment). If no key is set up, you see not logged in: set ATLAS_API_KEY or run: atlas login --api-key <key> and the exit code is 2.

Profiles

A profile is a saved key plus an API address. Keep one per account or per use.

atlas login --api-key KEY_FOR_CLIENT_A --profile client-a
atlas login --api-key KEY_FOR_CLIENT_B --profile client-b

atlas login makes the profile you just saved the active one. List your profiles. The active one is marked.

atlas profile list
client-a — https://api.youratlas.com/v1/api
client-b (active) — https://api.youratlas.com/v1/api

Switch the active profile:

atlas profile use client-a

It prints Switched to profile "client-a". A name that doesn’t exist fails with profile "NAME" not found and exit code 2.

Sign out

# Remove the active profile
atlas logout
# Remove one profile
atlas logout --profile client-b

It prints Logged out. This removes the key from your computer. It does not delete the key in the Atlas app. To turn a key off, delete it in the app.

Where the key is stored

Profiles are saved in ~/.atlas/config (on Windows, %USERPROFILE%\.atlas\config). Only you can read the file (permissions 0600). The key is stored as plain text in it. Don’t commit the file or copy it to shared machines.

active_profile: default
profiles:
default:
api_key: YOUR_API_KEY
base_url: https://api.youratlas.com/v1/api
spec_url: https://cdn.youratlas.com/atlas-cli/openapi.yaml
output_format: json
  • spec_url is where the CLI reads the API definition its commands come from. You don’t need to change it.
  • output_format is the default output: json, table or yaml.

Use a key without signing in

Set ATLAS_API_KEY and the CLI uses it for every command. Nothing is written to disk. It overrides the active profile. ATLAS_BASE_URL does the same for the API address.

export ATLAS_API_KEY="$YOUR_SECRET_VARIABLE"
atlas campaign get-all-campaigns

This is the best way to run the CLI in CI. See Scripting and CI.

Next