Skip to content
Start here

Update catch-all rule

client.EmailRouting.Rules.CatchAlls.Update(ctx, params) (*RuleCatchAllUpdateResponse, error)
PUT/zones/{zone_id}/email/routing/rules/catch_all

Enable or disable catch-all routing rule, or change action to forward to a specific destination address. Forward actions require exactly one verified 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: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 Write
ParametersExpand Collapse
params RuleCatchAllUpdateParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Actions param.Field[[]CatchAllAction]

Body param: List actions for the catch-all routing rule.

Type CatchAllActionType

Type of action for catch-all rule.

One of the following:
const CatchAllActionTypeDrop CatchAllActionType = "drop"
const CatchAllActionTypeForward CatchAllActionType = "forward"
const CatchAllActionTypeWorker CatchAllActionType = "worker"
Value []stringOptional
Matchers param.Field[[]CatchAllMatcher]

Body param: List of matchers for the catch-all routing rule.

Type CatchAllMatcherType

Type of matcher. Default is ‘all’.

Enabled param.Field[RuleCatchAllUpdateParamsEnabled]Optional

Body param: Routing rule status.

const RuleCatchAllUpdateParamsEnabledTrue RuleCatchAllUpdateParamsEnabled = true
const RuleCatchAllUpdateParamsEnabledFalse RuleCatchAllUpdateParamsEnabled = false
Name param.Field[string]Optional

Body param: Routing rule name.

maxLength256
OwnerWorkerTag param.Field[string]Optional

Body param: Public tag (script_tag) of the Worker that owns this rule. Required when source is wrangler.

maxLength32
Source param.Field[RuleCatchAllUpdateParamsSource]Optional

Body param: Who manages the rule. api covers dashboard, generic API, and Terraform; wrangler means the rule is managed by a Worker’s wrangler.jsonc. Defaults to api when omitted on write.

const RuleCatchAllUpdateParamsSourceAPI RuleCatchAllUpdateParamsSource = "api"
const RuleCatchAllUpdateParamsSourceWrangler RuleCatchAllUpdateParamsSource = "wrangler"
ReturnsExpand Collapse
type RuleCatchAllUpdateResponse struct{…}
ID stringOptional

Routing rule identifier.

maxLength32
Actions []CatchAllActionOptional

List actions for the catch-all routing rule.

Type CatchAllActionType

Type of action for catch-all rule.

One of the following:
const CatchAllActionTypeDrop CatchAllActionType = "drop"
const CatchAllActionTypeForward CatchAllActionType = "forward"
const CatchAllActionTypeWorker CatchAllActionType = "worker"
Value []stringOptional
Enabled RuleCatchAllUpdateResponseEnabledOptional

Routing rule status.

One of the following:
const RuleCatchAllUpdateResponseEnabledTrue RuleCatchAllUpdateResponseEnabled = true
const RuleCatchAllUpdateResponseEnabledFalse RuleCatchAllUpdateResponseEnabled = false
Matchers []CatchAllMatcherOptional

List of matchers for the catch-all routing rule.

Type CatchAllMatcherType

Type of matcher. Default is ‘all’.

Name stringOptional

Routing rule name.

maxLength256
Source RuleCatchAllUpdateResponseSourceOptional

Who manages the rule. api covers dashboard, generic API, and Terraform; wrangler means the rule is managed by a Worker’s wrangler.jsonc. Defaults to api when omitted on write.

One of the following:
const RuleCatchAllUpdateResponseSourceAPI RuleCatchAllUpdateResponseSource = "api"
const RuleCatchAllUpdateResponseSourceWrangler RuleCatchAllUpdateResponseSource = "wrangler"
DeprecatedTag stringOptional

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

maxLength32

Update catch-all 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"),
  )
  catchAll, err := client.EmailRouting.Rules.CatchAlls.Update(context.TODO(), email_routing.RuleCatchAllUpdateParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Actions: cloudflare.F([]email_routing.CatchAllActionParam{email_routing.CatchAllActionParam{
      Type: cloudflare.F(email_routing.CatchAllActionTypeForward),
    }}),
    Matchers: cloudflare.F([]email_routing.CatchAllMatcherParam{email_routing.CatchAllMatcherParam{
      Type: cloudflare.F(email_routing.CatchAllMatcherTypeAll),
    }}),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", catchAll.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": "all"
      }
    ],
    "name": "Send to user@example.net rule.",
    "source": "api",
    "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": "all"
      }
    ],
    "name": "Send to user@example.net rule.",
    "source": "api",
    "tag": "a7e6fb77503c41d8a7f3113c6918f10c"
  }
}