Skip to content
Start here

Get routing rule

client.EmailRouting.Rules.Get(ctx, ruleIdentifier, query) (*EmailRoutingRule, error)
GET/zones/{zone_id}/email/routing/rules/{rule_identifier}

Get information for a specific routing rule already created.

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
ruleIdentifier string

Routing rule identifier.

maxLength32
query RuleGetParams
ZoneID param.Field[string]

Identifier.

maxLength32
ReturnsExpand Collapse
type EmailRoutingRule struct{…}
ID stringoptional

Routing rule identifier.

maxLength32
Actions []Actionoptional

List actions patterns.

Type ActionType

Type of supported action.

One of the following:
const ActionTypeDrop ActionType = "drop"
const ActionTypeForward ActionType = "forward"
const ActionTypeWorker ActionType = "worker"
Value []stringoptional
Enabled EmailRoutingRuleEnabledoptional

Routing rule status.

One of the following:
const EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true
const EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false
Matchers []Matcheroptional

Matching patterns to forward to your actions.

Type MatcherType

Type of matcher.

One of the following:
const MatcherTypeAll MatcherType = "all"
const MatcherTypeLiteral MatcherType = "literal"
Field MatcherFieldoptional

Field for type matcher.

Value stringoptional

Value for matcher.

maxLength90
Name stringoptional

Routing rule name.

maxLength256
Priority float64optional

Priority of the routing rule.

minimum0
DeprecatedTag stringoptional

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

maxLength32

Get routing rule

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/email_routing"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  emailRoutingRule, err := client.EmailRouting.Rules.Get(
    context.TODO(),
    "a7e6fb77503c41d8a7f3113c6918f10c",
    email_routing.RuleGetParams{
      ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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"
  }
}
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"
  }
}