@tklein1801/cloudflare-email-routing
v0.1.1
Published
CLI to create Cloudflare Email Routing forwarding rules for proxy email addresses.
Readme
cloudflare-email-routing
CLI tool for managing Cloudflare Email Routing forwarding rules and destination addresses.
Installation
npm install --global @tklein1801/cloudflare-email-routing
cer --help
# The long command name is also available:
cloudflare-email-routing --helpPrerequisites
- A Cloudflare account with a managed domain.
- An API token with access to the account and the required Email Routing permissions.
- The API token exported as
CLOUDFLARE_API_TOKENor stored in a local.envfile.
export CLOUDFLARE_API_TOKEN=your-tokenRun the configuration check before using the API:
cer config doctor
cer config doctor --jsonThe token is never accepted as a command-line flag, so it does not appear in shell history or process listings.
Commands
Without a command, cer displays the help dialog. Use cer interactive to open the interactive menu. Every operation is also available as a scriptable subcommand:
The root invocation displays an orange ASCII banner. Subcommands and JSON output remain free of decorative output.
cer accounts list
cer addresses list
cer addresses create <email>
cer addresses delete <address-id>
cer rules list
cer rules create <alias> <destination>
cer rules delete <rule-id>Account and zone values can be selected interactively, provided through flags, or configured with environment variables:
cer addresses list --account-id ACCOUNT_ID
cer rules list --account-id ACCOUNT_ID --zone example.com
cer rules list --account-id ACCOUNT_ID --zone-id ZONE_IDThe following environment variables are supported:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_IDCLOUDFLARE_ZONE_IDCLOUDFLARE_ZONE
Automation
Use --non-interactive to fail instead of prompting, --yes to skip destructive-operation confirmations, and --json for machine-readable output:
cer rules create newsletter [email protected] \
--account-id ACCOUNT_ID \
--zone example.com \
--non-interactive \
--yes \
--json
cer addresses list --account-id ACCOUNT_ID --json
cer rules list --account-id ACCOUNT_ID --zone example.com --all --filter newsletter --jsonDestructive commands require confirmation by default. In non-interactive mode they require --yes.
rules create checks existing matchers before creating a rule and refuses duplicate aliases. addresses list supports --verified; rules list supports --all and --filter.
API Token Permissions
Scope the token to the exact domain whenever possible. Wildcard zone permissions are not recommended.
Accounts
The token must have access to the account.
Zones
- Zones: Zone Read
Email Routing
- Email Routing: Routing Write
- Email Routing: Addresses Write
See the token permission overview and the Cloudflare API token documentation.
Development
npm install
npm run format:check
npm test
npm run build
npm pack --dry-runThe CLI is implemented with oclif. Commands are discovered from src/commands and compiled to dist/commands.
The test suite uses Vitest.
