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 specific destination address. Forward actions require all destination addresses to be verified.

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
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
DeprecatedTag stringOptional

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

maxLength32

Update catch-all rule

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/email_routing"
  "github.com/stainless-sdks/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.",
    "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.",
    "tag": "a7e6fb77503c41d8a7f3113c6918f10c"
  }
}