# Account Rules ## List account or zone routing rules `client.emailRouting.accountRules.list(AccountRuleListParamsparams?, RequestOptionsoptions?): V4PagePaginationArray` **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` - `account_id?: string` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `zone_id?: string` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - `enabled?: true | false` Query param: Filter by enabled routing rules. - `true` - `false` - `page?: number` Query param: Page number of paginated results. - `per_page?: number` Query param: Maximum number of results per page. ### Returns - `AccountRule` - `id?: string` Routing rule identifier. - `actions?: Array` List actions patterns. - `type: "drop" | "forward" | "worker"` Type of supported action. - `"drop"` - `"forward"` - `"worker"` - `value?: Array` - `enabled?: true | false` Routing rule status. - `true` - `false` - `matchers?: Array` Matching patterns to forward to your actions. - `type: "all" | "literal"` Type of matcher. - `"all"` - `"literal"` - `field?: "to"` Field for type matcher. - `"to"` - `value?: string` Value for matcher. - `name?: string` Routing rule name. - `priority?: number` Priority of the routing rule. - `source?: "api" | "wrangler"` 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. - `"api"` - `"wrangler"` - `tag?: string` Routing rule tag. (Deprecated, replaced by routing rule identifier) - `zone?: Zone` Zone information for the routing rule. - `name?: string` Zone name. - `tag?: string` Zone tag. ### Example ```typescript 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 accountRule of client.emailRouting.accountRules.list({ account_id: 'account_id', })) { console.log(accountRule.id); } ``` #### 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 } } ``` ## Domain Types ### Account Rule - `AccountRule` - `id?: string` Routing rule identifier. - `actions?: Array` List actions patterns. - `type: "drop" | "forward" | "worker"` Type of supported action. - `"drop"` - `"forward"` - `"worker"` - `value?: Array` - `enabled?: true | false` Routing rule status. - `true` - `false` - `matchers?: Array` Matching patterns to forward to your actions. - `type: "all" | "literal"` Type of matcher. - `"all"` - `"literal"` - `field?: "to"` Field for type matcher. - `"to"` - `value?: string` Value for matcher. - `name?: string` Routing rule name. - `priority?: number` Priority of the routing rule. - `source?: "api" | "wrangler"` 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. - `"api"` - `"wrangler"` - `tag?: string` Routing rule tag. (Deprecated, replaced by routing rule identifier) - `zone?: Zone` Zone information for the routing rule. - `name?: string` Zone name. - `tag?: string` Zone tag.