Before you can use the Checkly CLI, you need to authenticate with your Checkly account.

Login

The primary way to authenticate is using the interactive login command:
Terminal
npx checkly login
This command will:
  • Open your default browser to the Checkly authentication page
  • Prompt you to log in to your Checkly account
  • Generate an API key that the CLI will use for authentication
  • Store the credentials securely on your local machine

Log Out

To log out and clear your stored credentials:
Terminal
npx checkly logout
This will remove the stored API key from your local machine.

Other Authentication Options

Environment Variables

You can also authenticate using environment variables, which is useful for CI/CD pipelines and automated environments: To get your API key:
  1. Log in to your Checkly dashboard
  2. Navigate to Account SettingsAPI Keys
  3. Create a new API key
  4. Use the key in your environment variables or CLI configuration
Set the account id and API key as follows:
Terminal
# Set your Checkly API key
export CHECKLY_API_KEY=your_api_key_here

# Set your Checkly account ID (optional, CLI will detect automatically)
export CHECKLY_ACCOUNT_ID=your_account_id_here
To verify you’re properly authenticated:
Terminal
npx checkly whoami
This will display your account information and confirm your authentication status.

Multiple Accounts

If you work with multiple Checkly accounts, you can switch between them:
Terminal
# Switch to a different account using interactive prompt
npx checkly switch

# Switch to a different account using the account id
npx checkly switch --account-id your_account_id

# View current account
npx checkly whoami

Security Best Practices

  • Never commit API keys to version control
  • Use environment variables in production environments
  • Rotate API keys regularly for security

Troubleshooting

Common Issues

“Authentication failed” error:
  • Verify your API key is correct
  • Check that your account ID is correct (if specified)
  • Ensure your API key hasn’t expired
“Browser didn’t open” error:
  • Decline to open the browser automatically and navigate to the authentication URL shown in the terminal
  • Copy and paste the URL into your browser