atmn CLI uses OAuth 2.0 for secure authentication and automatically manages API keys for both sandbox and production environments.
OAuth Login Flow
Authenticate with your Autumn account using the login command:Interactive Mode
When running in an interactive terminal, the CLI provides a beautiful login experience:- Local Callback Server: Starts a temporary server on ports 31448-31452
- Browser Integration: Opens your default browser to Autumn’s Auth0 login page
- Organization Selection: Choose which organization to authenticate with
- Automatic Key Generation: Creates sandbox and production API keys
- Environment Setup: Saves keys to your
.envfile
Headless Mode
For CI/CD environments or when no TTY is available:- The CLI opens your browser with the OAuth URL
- Provides a fallback URL you can copy/paste manually
- Waits for the OAuth callback with a timeout
The OAuth flow uses PKCE (Proof Key for Code Exchange) for enhanced security.
API Key Management
Key Types and Prefixes
The CLI generates two API keys with distinct prefixes:Sandbox key with prefix
am_sk_test_* — for development and testingProduction key with prefix
am_sk_live_* — for production environmentEnvironment File Structure
Keys are automatically saved to a.env file in your current directory:
Key Resolution
The CLI looks for environment files in this order:- Current directory
.env - Parent directories (walks up the directory tree)
- Root directory
.env
Environment Selection
Control which environment and API server the CLI uses with global flags:Use production environment instead of sandbox
Use localhost:8080 API server instead of api.useautumn.com
Flag Combinations
Environment URLs
https://api.useautumn.comhttps://app.useautumn.comhttp://localhost:8080http://localhost:3000Authentication Commands
Check Environment
Display your current authentication status and organization info:Logout
Remove stored API keys from your.env file:
AUTUMN_SECRET_KEY and AUTUMN_PROD_SECRET_KEY from your environment file.
Error Handling
Automatic Re-authentication
The CLI automatically handles expired or invalid tokens:- 401 Unauthorized responses trigger the OAuth flow
- New tokens are generated and stored
- The original request is retried
- You’re notified of the re-authentication
Common Issues
No API key found:atmn login to generate API keys
Invalid API key:
--prod flag or login again to generate production keys
Security Best Practices
Keep your API keys secure:
- Add
.envto your.gitignorefile - Never commit API keys to version control
- Use different keys for development and production
- Rotate keys regularly through the Autumn dashboard

