## List account or zone routing rules `client.EmailRouting.AccountRules.List(ctx, params) (*V4PagePaginationArray[AccountRule], error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/email/routing/rules` Lists existing routing rules across all zones in the account or zone. ### Parameters - `params AccountRuleListParams` - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - `Enabled param.Field[AccountRuleListParamsEnabled]` Query param: Filter by enabled routing rules. - `const AccountRuleListParamsEnabledTrue AccountRuleListParamsEnabled = true` - `const AccountRuleListParamsEnabledFalse AccountRuleListParamsEnabled = false` - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Maximum number of results per page. ### Returns - `type AccountRule struct{…}` - `ID string` Routing rule identifier. - `Actions []Action` List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Enabled AccountRuleEnabled` Routing rule status. - `const AccountRuleEnabledTrue AccountRuleEnabled = true` - `const AccountRuleEnabledFalse AccountRuleEnabled = false` - `Matchers []Matcher` Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Name string` Routing rule name. - `Priority float64` Priority of the routing rule. - `Source AccountRuleSource` 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 AccountRuleSourceAPI AccountRuleSource = "api"` - `const AccountRuleSourceWrangler AccountRuleSource = "wrangler"` - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) - `Zone AccountRuleZone` Zone information for the routing rule. - `Name string` Zone name. - `Tag string` Zone tag. ### Example ```go 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"), ) page, err := client.EmailRouting.AccountRules.List(context.TODO(), email_routing.AccountRuleListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "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, "source": "api", "tag": "a7e6fb77503c41d8a7f3113c6918f10c", "zone": { "name": "example.com", "tag": "023e105f4ecef8ad9ca31a8372d0c353" } } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 1, "total_pages": 100 } } ```