checkly auth
Manage Checkly CLI authentication.
Quick start
# Interactive login (browser-based)
npx checkly login
# Check authentication status
npx checkly whoami
# Switch to a known account in multi-account setups
npx checkly switch --account-id <account-id>
# Log out of saved local-session credentials
npx checkly logout
# Manual configuration (for CI/CD)
export CHECKLY_API_KEY="your-api-key"
export CHECKLY_ACCOUNT_ID="your-account-id"
Authentication methods
Interactive login (recommended for local development)
npx checkly login
Opens browser to authenticate and automatically saves credentials to your system config.
Credential storage location:
- Linux/macOS:
~/.config/@checkly/cli/config.json - Windows:
%APPDATA%\@checkly\cli\config.json
Environment variables (recommended for CI/CD)
export CHECKLY_API_KEY="cu_abc123..."
export CHECKLY_ACCOUNT_ID="12345"
# Test authentication
npx checkly whoami
Getting your credentials:
- Log into app.checklyhq.com
- Navigate to Account Settings → API Keys
- Create new API key with appropriate permissions
- Copy Account ID from URL or account settings
Environment variables take precedence over saved npx checkly login credentials. npx checkly whoami tells you when the active account is resolved from CHECKLY_API_KEY / CHECKLY_ACCOUNT_ID, and npx checkly logout warns if those env vars still keep you authenticated after local session cleanup.
Configuration file (manual)
Create/edit config file at ~/.config/@checkly/cli/config.json:
{
"apiKey": "cu_abc123...",
"accountId": "12345"
}
Workflows
First-time setup
Sign up for Checkly account (if needed):
# Opens signup page npx checkly loginAuthenticate CLI:
npx checkly loginVerify authentication:
npx checkly whoamiExpected output:
Logged in as john@example.com Account: Acme Corp (ID: 12345)Initialize project:
npm create checkly@latest
Switching accounts
If you have multiple Checkly accounts:
List or verify the current account:
npx checkly whoamiSwitch directly when you know the target account ID:
npx checkly switch --account-id <account-id>If you need a fresh browser login, clear saved local-session credentials first:
npx checkly logout --force npx checkly loginVerify the selected account:
npx checkly whoami
If CHECKLY_API_KEY or CHECKLY_ACCOUNT_ID are set in the shell or a project .env, they override the saved account. Remove or update those variables before using login / switch to change the effective account.
CI/CD authentication
For automated pipelines (GitHub Actions, GitLab CI, etc.):
Create API key in Checkly UI:
- Navigate to Account Settings → API Keys
- Click "Create API Key"
- Name: "CI/CD Pipeline"
- Permissions: Read/Write (for deploy)
- Copy the key (starts with
cu_)
Add secrets to CI/CD platform:
CHECKLY_API_KEY: Your API keyCHECKLY_ACCOUNT_ID: Your account ID
Use in pipeline:
# GitHub Actions example - name: Test checks env: CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }} CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }} run: npx checkly test - name: Deploy checks env: CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }} CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }} run: npx checkly deploy --force
Troubleshooting
"Could not find Checkly credentials"
Cause: No authentication configured
Solution:
# Option 1: Interactive login
npx checkly login
# Option 2: Set environment variables
export CHECKLY_API_KEY="your-key"
export CHECKLY_ACCOUNT_ID="your-account-id"
whoami still shows an account after logout
Cause: CHECKLY_API_KEY or CHECKLY_ACCOUNT_ID are still set in the shell or loaded from a project .env. npx checkly logout can clear saved local-session credentials but cannot remove environment variables.
Solution:
# Inspect environment-backed credentials without printing secret values
env | grep '^CHECKLY_.*=' | sed 's/=.*$/=<set>/'
# Unset for the current shell if you want to use browser login credentials instead
unset CHECKLY_API_KEY CHECKLY_ACCOUNT_ID
npx checkly whoami
"401 Unauthorized"
Possible causes:
- API key has been deleted or revoked
- API key doesn't have required permissions
- Account ID doesn't match API key
Solution:
Verify credentials:
npx checkly whoamiIf invalid, re-authenticate:
npx checkly loginFor CI/CD, regenerate API key in Checkly UI
"Account not found"
Cause: Account ID is incorrect
Solution:
- Log into app.checklyhq.com
- Check URL:
app.checklyhq.com/accounts/{ACCOUNT_ID}/... - Or check Account Settings → Account ID
- Update
CHECKLY_ACCOUNT_IDenvironment variable
Permission errors during deploy
Cause: API key has read-only permissions
Solution:
- Go to Account Settings → API Keys in Checkly UI
- Create new API key with "Read/Write" permissions
- Update your API key
Environment variables reference
| Variable | Required | Description |
|---|---|---|
CHECKLY_API_KEY |
Yes | API key (starts with cu_) |
CHECKLY_ACCOUNT_ID |
Yes | Numeric account ID |
CHECKLY_API_URL |
No | Override the local API URL when CHECKLY_ENV=local (default: http://127.0.0.1:3000) |
CHECKLY_MQTT_URL |
No | Override the local events/MQTT broker when CHECKLY_ENV=local |
CHECKLY_SKIP_AUTH |
No | Skip authentication (for debugging flags) |
CHECKLY_MQTT_URL is advanced troubleshooting configuration for local or custom setups where test-session event streams come from a different broker. It is analogous to CHECKLY_API_URL for local endpoint overrides, not a normal hosted Checkly credential or default CI setting.
Security best practices
Local development
- ✅ Use
npx checkly login(credentials stored securely) - ✅ Add config file to
.gitignore(if using manual config) - ❌ Don't commit API keys to version control
CI/CD pipelines
- ✅ Store credentials as encrypted secrets
- ✅ Use API keys with minimal required permissions
- ✅ Rotate API keys regularly
- ❌ Don't log API keys in pipeline output
API key management
- ✅ Create separate API keys for different purposes (CI/CD, local dev)
- ✅ Name keys descriptively ("GitHub Actions Deploy", "John's Laptop")
- ✅ Revoke unused or compromised keys immediately
- ❌ Don't share API keys between team members
Related Skills
Next steps after authentication:
- See
checkly-configto configure your project - See
checkly-testto run checks locally - See
checkly-deployto deploy checks to Checkly
Project setup:
- New project: Use
npm create checkly@latest(includes auth setup) - Existing project: Install
checklypackage and authenticate