CLI Authentication
CLI Authentication
Section titled “CLI Authentication”Learn how to authenticate with the mailiam CLI and manage your API credentials securely.
Installation
Section titled “Installation”First, install the mailiam CLI globally:
npm install -g mailiamGetting Started
Section titled “Getting Started”1. Create a mailiam Account
Section titled “1. Create a mailiam Account”If you don’t have an account yet, create one using the CLI:
mailiam signupThis will guide you through creating your account and provide you with an API key.
2. Set Your API Key
Section titled “2. Set Your API Key”Once you have your API key, configure it with the CLI:
mailiam auth set-key YOUR_API_KEYThe API key will be stored securely in your system’s credential store.
Authentication Methods
Section titled “Authentication Methods”Global API Key (Recommended)
Section titled “Global API Key (Recommended)”Set your API key globally to use across all projects:
mailiam auth set-key mlm_your_api_key_hereEnvironment Variable
Section titled “Environment Variable”Alternatively, set the API key as an environment variable:
export MAILIAM_API_KEY=mlm_your_api_key_hereAdd this to your shell profile (.bashrc, .zshrc, etc.) to make it persistent.
Project-Specific Configuration
Section titled “Project-Specific Configuration”For project-specific setups, you can also set the API key in your project directory:
cd your-projectmailiam auth set-key YOUR_API_KEY --localManaging Authentication
Section titled “Managing Authentication”Check Authentication Status
Section titled “Check Authentication Status”Verify your authentication is working:
mailiam auth statusThis command shows:
- Whether you’re authenticated
- Which API key is being used (masked for security)
- Your account information
View Authentication Help
Section titled “View Authentication Help”Get detailed help for authentication commands:
mailiam auth --helpAvailable authentication commands:
mailiam auth set-key <key>- Set your API keymailiam auth status- Check authentication statusmailiam auth clear- Remove stored credentials
API Key Format
Section titled “API Key Format”mailiam API keys follow this format:
- Prefix:
mlm_ - Length: 32+ characters
- Example:
mlm_sk_abc123def456...
Security Best Practices
Section titled “Security Best Practices”1. Keep API Keys Secure
Section titled “1. Keep API Keys Secure”- Never commit API keys to version control
- Use environment variables in production
- Rotate keys regularly
- Don’t share keys via insecure channels
2. Environment-Specific Keys
Section titled “2. Environment-Specific Keys”Use different API keys for different environments:
# Developmentexport MAILIAM_API_KEY=mlm_dev_your_dev_key
# Productionexport MAILIAM_API_KEY=mlm_prod_your_prod_key3. Team Management
Section titled “3. Team Management”For teams, each developer should have their own API key. Don’t share keys between team members.
Credential Storage
Section titled “Credential Storage”Where Credentials Are Stored
Section titled “Where Credentials Are Stored”The mailiam CLI stores credentials securely using your operating system’s credential store:
- macOS: Keychain Access
- Windows: Windows Credential Manager
- Linux: Secret Service API (libsecret)
Manual Credential Management
Section titled “Manual Credential Management”If needed, you can manually manage credentials:
# Clear stored credentialsmailiam auth clear
# Re-authenticatemailiam auth set-key YOUR_NEW_API_KEYTroubleshooting Authentication
Section titled “Troubleshooting Authentication”Common Issues
Section titled “Common Issues”“API key not found” error
# Check if key is setmailiam auth status
# Set your API keymailiam auth set-key YOUR_API_KEY“Invalid API key” error
- Verify your API key is correct
- Check if the key has expired
- Ensure you have the correct permissions
“Authentication failed” error
- Check your internet connection
- Verify the API endpoint is accessible
- Try setting the key again
Network Configuration
Section titled “Network Configuration”If you’re behind a corporate firewall or proxy:
# Set proxy (if needed)export HTTP_PROXY=http://your-proxy:8080export HTTPS_PROXY=http://your-proxy:8080
# Then authenticatemailiam auth set-key YOUR_API_KEYGetting Help
Section titled “Getting Help”If you continue to have authentication issues:
- Check your API key in the mailiam dashboard
- Try creating a new API key
- Contact support at support@mailiam.dev
- Run
mailiam auth status --debugfor detailed error information
Integration with CI/CD
Section titled “Integration with CI/CD”GitHub Actions
Section titled “GitHub Actions”name: Deploy mailiam Configon: [push]jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '18' - name: Install mailiam CLI run: npm install -g mailiam - name: Deploy configuration env: MAILIAM_API_KEY: ${{ secrets.MAILIAM_API_KEY }} run: mailiam pushOther CI Systems
Section titled “Other CI Systems”For other CI systems, set MAILIAM_API_KEY as a secret environment variable and the CLI will automatically use it.
Next Steps
Section titled “Next Steps”Once authenticated, you can: