---
title: "Authentication"
description: "Authenticate the Edge CLI with an API key: generate a key in the console, log in with edge auth login, use the EDGE_API_KEY variable, and set up CI/CD."
url: "https://edge.network/docs/cli/authentication"
section: "CLI"
---

# Authentication

Authenticate the CLI with your Edge account using API keys.

## 1. Generate an API key

Create an API key in your Edge account:

1. Go to [Account → API Keys](/console/api-keys).
2. Click **Create API Key**.
3. Give it a name (e.g. "CLI - MacBook").
4. Copy the key immediately. It won't be shown again.

> [!WARNING]
> API keys have the same permissions as your user account. Keep them secure and never commit them to version control.

The same key also authenticates direct HTTPS calls. See the [REST API documentation](/docs/api).

## 2. Log in

Run the login command and paste your API key when prompted (interactive), or pass the key directly, which is useful for scripts (non-interactive):

```text tab="Interactive"
$ edge auth login
? Enter your API key: ek_live_••••••••••••••••••••••••

✓ Authenticated successfully
  Account: Acme Corp
  User: john@example.com
```

```bash tab="Non-interactive"
edge auth login --key ek_live_abc123def456...
```

## Check authentication status

```text
$ edge auth status
✓ Authenticated

Account:  Acme Corp
User:     john@example.com
Key:      ek_live_abc1****
Expires:  Never
```

## Log out

Remove stored credentials:

```text
$ edge auth logout
✓ Credentials removed
```

## Environment variable

You can also authenticate using the `EDGE_API_KEY` environment variable:

```bash
# Set for current session
export EDGE_API_KEY=ek_live_abc123def456...

# Or add to your shell profile (~/.bashrc, ~/.zshrc)
echo 'export EDGE_API_KEY=ek_live_abc123...' >> ~/.zshrc
```

The environment variable takes precedence over the stored config file.

## Config file location

Credentials are stored in:

- **macOS / Linux:** `~/.edge/config.json`
- **Windows:** `%USERPROFILE%\.edge\config.json`

Example config:

```json
{
  "api_key": "ek_live_abc123def456...",
  "default_region": "london",
  "output": "table"
}
```

## CI/CD integration

Use environment variables in your CI/CD pipelines:

```yaml
# GitHub Actions example
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Edge CLI
        run: curl -fsSL https://edge.network/install.sh | sh
      
      - name: Deploy
        env:
          EDGE_API_KEY: ${{ secrets.EDGE_API_KEY }}
        run: |
          edge cdn purge my-deployment
          edge storage sync ./dist my-bucket/app/
```

> [!TIP]
> Create a dedicated API key for CI/CD with a descriptive name like "GitHub Actions - Production".

## Authentication priority

The CLI checks for credentials in this order:

1. **Command-line flag:** `--api-key`
2. **Environment variable:** `EDGE_API_KEY`
3. **Config file:** `~/.edge/config.json`

## Activity tracking

All actions performed via the CLI are logged in your [account activity log](/docs/account/audit-log) with full attribution:

- **Source badge:** CLI actions are tagged with a CLI badge to distinguish them from web or API actions
- **User attribution:** for accounts with team members, the activity log shows which user performed each action
- **Full audit trail:** all create, update and delete operations are logged with timestamps

This helps teams track automated deployments, distinguish CI/CD activity from manual changes, and maintain compliance records.

## Next steps

- [Compute commands](/docs/cli/compute) — Manage virtual machines
- [Configuration](/docs/cli/configuration) — Customise CLI settings
