---
title: "CLI Authentication"
description: "Set up API key authentication for the Edge CLI."
url: https://edge.network/docs/cli/authentication/
---

# CLI Authentication

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:

- Go to [Account → API Keys](https://account.edge.network/api-keys)
- Click **Create API Key**
- Give it a name (e.g., "CLI - MacBook")
- Copy the key immediately — it won't be shown again

Important

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](https://edge.network/docs/api).

2

## Log In

### Interactive Login

Run the login command and paste your API key when prompted:

```
$ edge auth login
? Enter your API key: ek_live_••••••••••••••••••••••••

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

### Non-Interactive Login

Pass the key directly (useful for scripts):

```
edge auth login --key ek_live_abc123def456...
```

## Check Authentication Status

```
$ edge auth status
✓ Authenticated

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

## Log Out

Remove stored credentials:

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

## Environment Variable

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

```
# 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:

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

Example config:

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

## CI/CD Integration

Use environment variables in your CI/CD pipelines:

```
# 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:

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

## Activity Tracking

All actions performed via the CLI are logged in your [account activity log](https://edge.network/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 Manage virtual machines](https://edge.network/docs/cli/compute) [Configuration Customize CLI settings](https://edge.network/docs/cli/configuration)
[Back to Docs](https://edge.network/docs) [Need help?](https://edge.network/support)
