Skip to main content

rules

Creates, updates, deletes, gets or lists a rules resource.

Overview

Namerules
TypeResource
Idcloudflare.email_routing.rules

Fields

The following fields are returned by SELECT queries:

Get routing rule response

NameDatatypeDescription
errorsarray
messagesarray
resultobject
successbooleanWhether the API call was successful. (true)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectrule_identifier, zone_idGet information for a specific routing rule already created.
listselectzone_idpage, per_page, enabledLists existing routing rules.
createinsertzone_id, actions, matchersRules consist of a set of criteria for matching emails (such as an email being sent to a specific custom email address) plus a set of actions to take on the email (like forwarding it to a specific destination address). Forward actions require all destination addresses to be verified.
updatereplacerule_identifier, zone_id, actions, matchersUpdate actions and matches, or enable/disable specific routing rules. Forward actions require all destination addresses to be verified.
deletedeleterule_identifier, zone_idDelete a specific routing rule.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
rule_identifierstring
zone_idstringThe Cloudflare zone ID.
enabledboolean
pagenumber
per_pagenumber

SELECT examples

Get information for a specific routing rule already created.

SELECT
errors,
messages,
result,
success
FROM cloudflare.email_routing.rules
WHERE rule_identifier = '{{ rule_identifier }}' -- required
AND zone_id = '{{ zone_id }}' -- required
;

INSERT examples

Rules consist of a set of criteria for matching emails (such as an email being sent to a specific custom email address) plus a set of actions to take on the email (like forwarding it to a specific destination address). Forward actions require all destination addresses to be verified.

INSERT INTO cloudflare.email_routing.rules (
actions,
enabled,
matchers,
name,
priority,
zone_id
)
SELECT
'{{ actions }}' /* required */,
{{ enabled }},
'{{ matchers }}' /* required */,
'{{ name }}',
{{ priority }},
'{{ zone_id }}'
RETURNING
errors,
messages,
result,
success
;

REPLACE examples

Update actions and matches, or enable/disable specific routing rules. Forward actions require all destination addresses to be verified.

REPLACE cloudflare.email_routing.rules
SET
actions = '{{ actions }}',
enabled = {{ enabled }},
matchers = '{{ matchers }}',
name = '{{ name }}',
priority = {{ priority }}
WHERE
rule_identifier = '{{ rule_identifier }}' --required
AND zone_id = '{{ zone_id }}' --required
AND actions = '{{ actions }}' --required
AND matchers = '{{ matchers }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Delete a specific routing rule.

DELETE FROM cloudflare.email_routing.rules
WHERE rule_identifier = '{{ rule_identifier }}' --required
AND zone_id = '{{ zone_id }}' --required
;