Skip to main content

Overview

Cloudflare Email Routing allows you to create custom email addresses for your domain and route them to your preferred email inbox. Manage routing rules, destination addresses, and DNS records.

Initialize the client

Settings

Manage Email Routing settings for a zone.

Get settings

Get information about Email Routing settings for your zone.
string
required
Zone identifier
string
Email Routing settings identifier
boolean
State of Email Routing (enabled or disabled)
string
Domain of your zone
string
Account status: ready, unconfigured, misconfigured, misconfigured/locked, or unlocked
string
When the settings were created
string
When the settings were last modified
boolean
Whether the user skipped the configuration wizard

Enable Email Routing (deprecated)

Enable Email Routing for your zone. This adds and locks necessary MX and SPF records.

Disable Email Routing (deprecated)

Disable Email Routing for your zone. This removes additional MX records.

Rules

Manage email routing rules.

Create a rule

Create a new routing rule.
string
required
Zone identifier
array
required
Matching rules to filter emails
array
required
Actions to perform on matched emails
boolean
Whether the rule is enabled (default: true)
string
Rule name
number
Rule priority (lower values execute first)

Update a rule

Update an existing routing rule.

List rules

List all routing rules for a zone.

Get a rule

Get details of a specific routing rule.

Delete a rule

Delete a routing rule.

Addresses

Manage destination email addresses.

Create an address

Add a verified destination address.
string
required
Account identifier
string
required
The email address to verify and use as a destination

List addresses

List all verified destination addresses.

Get an address

Get details of a destination address.

Delete an address

Remove a destination address.

DNS

Manage DNS records for Email Routing.
The DNS resource provides methods for managing MX and other DNS records required for Email Routing.

Types

Matcher

Defines how to match incoming emails.
'literal' | 'all'
Matcher type
'to' | 'from'
Email field to match against
string
Value to match (for literal matchers)

Action

Defines what to do with matched emails.
'forward' | 'worker' | 'drop'
Action type
string[]
Destination addresses (for forward action)

EmailRoutingRule

string
Rule identifier
string
Rule tag
string
Rule name
boolean
Whether the rule is active
Matcher[]
Matching conditions
Action[]
Actions to perform
number
Rule priority