Skip to content

CLI Authentication

Learn how to authenticate with the mailiam CLI and manage your API credentials securely.

First, install the mailiam CLI globally:

Terminal window
npm install -g mailiam

If you don’t have an account yet, create one using the CLI:

Terminal window
mailiam signup

This will guide you through creating your account and provide you with an API key.

Once you have your API key, configure it with the CLI:

Terminal window
mailiam auth set-key YOUR_API_KEY

The API key will be stored securely in your system’s credential store.

Set your API key globally to use across all projects:

Terminal window
mailiam auth set-key mlm_your_api_key_here

Alternatively, set the API key as an environment variable:

Terminal window
export MAILIAM_API_KEY=mlm_your_api_key_here

Add this to your shell profile (.bashrc, .zshrc, etc.) to make it persistent.

For project-specific setups, you can also set the API key in your project directory:

Terminal window
cd your-project
mailiam auth set-key YOUR_API_KEY --local

Verify your authentication is working:

Terminal window
mailiam auth status

This command shows:

  • Whether you’re authenticated
  • Which API key is being used (masked for security)
  • Your account information

Get detailed help for authentication commands:

Terminal window
mailiam auth --help

Available authentication commands:

  • mailiam auth set-key <key> - Set your API key
  • mailiam auth status - Check authentication status
  • mailiam auth clear - Remove stored credentials

mailiam API keys follow this format:

  • Prefix: mlm_
  • Length: 32+ characters
  • Example: mlm_sk_abc123def456...
  • Never commit API keys to version control
  • Use environment variables in production
  • Rotate keys regularly
  • Don’t share keys via insecure channels

Use different API keys for different environments:

Terminal window
# Development
export MAILIAM_API_KEY=mlm_dev_your_dev_key
# Production
export MAILIAM_API_KEY=mlm_prod_your_prod_key

For teams, each developer should have their own API key. Don’t share keys between team members.

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)

If needed, you can manually manage credentials:

Terminal window
# Clear stored credentials
mailiam auth clear
# Re-authenticate
mailiam auth set-key YOUR_NEW_API_KEY

“API key not found” error

Terminal window
# Check if key is set
mailiam auth status
# Set your API key
mailiam 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

If you’re behind a corporate firewall or proxy:

Terminal window
# Set proxy (if needed)
export HTTP_PROXY=http://your-proxy:8080
export HTTPS_PROXY=http://your-proxy:8080
# Then authenticate
mailiam auth set-key YOUR_API_KEY

If you continue to have authentication issues:

  1. Check your API key in the mailiam dashboard
  2. Try creating a new API key
  3. Contact support at support@mailiam.dev
  4. Run mailiam auth status --debug for detailed error information
name: Deploy mailiam Config
on: [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 push

For other CI systems, set MAILIAM_API_KEY as a secret environment variable and the CLI will automatically use it.

Once authenticated, you can: