Skip to content

feat: add wrangler email routing commands#12932

Draft
thomasgauvin wants to merge 2 commits intocloudflare:mainfrom
thomasgauvin:tgauvin/wrangler-email-routing-commands
Draft

feat: add wrangler email routing commands#12932
thomasgauvin wants to merge 2 commits intocloudflare:mainfrom
thomasgauvin:tgauvin/wrangler-email-routing-commands

Conversation

@thomasgauvin
Copy link
Contributor

@thomasgauvin thomasgauvin commented Mar 16, 2026

Summary

Adds wrangler email routing commands wrapping the Cloudflare Email Routing REST API.

Commands

wrangler email routing
├── list                                            # List zones with email routing status
├── settings       (--zone | --zone-id)             # Get settings for a zone
├── enable         (--zone | --zone-id)             # Enable email routing
├── disable        (--zone | --zone-id)             # Disable email routing
├── dns get        (--zone | --zone-id)             # Show required DNS records
├── dns unlock     (--zone | --zone-id)             # Unlock MX records
├── rules list/get/create/update/delete             # Routing rules CRUD
├── rules catch-all get/update                      # Catch-all rule
└── addresses list/get/create/delete                # Destination addresses (account-scoped)

Key design decisions

  • Zone resolution: --zone example.com (domain) or --zone-id abc123 (direct ID)
  • Follows VPC command pattern: createCommand(), fetchResult()/fetchPagedListResult()
  • OAuth scope: Adds email_routing:write to DefaultScopes. Bach MRs: staging / production
  • Concurrency-limited list: Fetches settings per-zone with limit of 5
  • Smart error handling: Distinguishes "not configured" from real API errors

Testing

  • 33 unit tests, all passing
  • Build passes

Add CLI commands wrapping the Cloudflare Email Routing REST API:

- wrangler email routing list - list zones with email routing status
- wrangler email routing settings/enable/disable - manage zone settings
- wrangler email routing dns get/unlock - DNS record management
- wrangler email routing rules list/get/create/update/delete - routing rules CRUD
- wrangler email routing rules catch-all get/update - catch-all rule management
- wrangler email routing addresses list/get/create/delete - destination addresses

Zone-scoped commands support --zone (domain) and --zone-id flags.
Address commands are account-scoped.

Also adds email_routing:write OAuth scope to DefaultScopes so wrangler login
grants the necessary permissions.
@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: d8f9478

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@LuisDuarte1 LuisDuarte1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the EMAIL team:

├── rules list/get/create/update/delete             # Routing rules CRUD
├── rules catch-all get/update                      # Catch-all rule

why do we have to have 2 seperate comands for rules that are not catch-alls and rules that are a catch-all? couldn't rules * also handle this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants