Skip to content
Start here

List routing rules

client.emailRouting.rules.list(RuleListParams { zone_id, enabled, page, per_page } params, RequestOptionsoptions?): V4PagePaginationArray<EmailRoutingRule { id, actions, enabled, 4 more } >
GET/zones/{zone_id}/email/routing/rules

Lists existing routing rules.

Security

API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Email Routing Rules WriteEmail Routing Rules Read
ParametersExpand Collapse
params: RuleListParams { zone_id, enabled, page, per_page }
zone_id: string

Path param: Identifier.

maxLength32
enabled?: true | false

Query param: Filter by enabled routing rules.

One of the following:
true
false
page?: number

Query param: Page number of paginated results.

minimum1
per_page?: number

Query param: Maximum number of results per page.

maximum50
minimum5
ReturnsExpand Collapse
EmailRoutingRule { id, actions, enabled, 4 more }
id?: string

Routing rule identifier.

maxLength32
actions?: Array<Action { type, value } >

List actions patterns.

type: "drop" | "forward" | "worker"

Type of supported action.

One of the following:
"drop"
"forward"
"worker"
value?: Array<string>
enabled?: true | false

Routing rule status.

One of the following:
true
false
matchers?: Array<Matcher { type, field, value } >

Matching patterns to forward to your actions.

type: "all" | "literal"

Type of matcher.

One of the following:
"all"
"literal"
field?: "to"

Field for type matcher.

value?: string

Value for matcher.

maxLength90
name?: string

Routing rule name.

maxLength256
priority?: number

Priority of the routing rule.

minimum0
Deprecatedtag?: string

Routing rule tag. (Deprecated, replaced by routing rule identifier)

maxLength32

List routing rules

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
  apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const emailRoutingRule of client.emailRouting.rules.list({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
})) {
  console.log(emailRoutingRule.id);
}
{
  "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"
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 1,
    "total_pages": 100
  }
}
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"
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 1,
    "total_pages": 100
  }
}