Create routing rule
POST/zones/{zone_id}/email/routing/rules
Rules consist of a set of criteria for matching emails (such as an email being sent to a specific custom email address) plus a set of actions to take on the email (like forwarding it to a specific destination address).
Security
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Body ParametersJSON
Create routing rule
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/email/routing/rules \
-H 'Content-Type: application/json' \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
-d '{
"actions": [
{
"type": "forward"
}
],
"matchers": [
{
"type": "literal"
}
],
"enabled": true,
"name": "Send to user@example.net rule."
}'{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"id": "a7e6fb77503c41d8a7f3113c6918f10c",
"actions": [
{
"type": "forward",
"value": [
"destinationaddress@example.net"
]
}
],
"enabled": true,
"matchers": [
{
"type": "literal",
"field": "to",
"value": "test@example.com"
}
],
"name": "Send to user@example.net rule.",
"priority": 0,
"tag": "a7e6fb77503c41d8a7f3113c6918f10c"
}
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"id": "a7e6fb77503c41d8a7f3113c6918f10c",
"actions": [
{
"type": "forward",
"value": [
"destinationaddress@example.net"
]
}
],
"enabled": true,
"matchers": [
{
"type": "literal",
"field": "to",
"value": "test@example.com"
}
],
"name": "Send to user@example.net rule.",
"priority": 0,
"tag": "a7e6fb77503c41d8a7f3113c6918f10c"
}
}