rules
Creates, updates, deletes, gets or lists a rules resource.
Overview
| Name | rules |
| Type | Resource |
| Id | cloudflare.email_routing.rules |
Fields
The following fields are returned by SELECT queries:
- get
- list
Get routing rule response
| Name | Datatype | Description |
|---|---|---|
errors | array | |
messages | array | |
result | object | |
success | boolean | Whether the API call was successful. (true) |
List routing rules response
| Name | Datatype | Description |
|---|---|---|
id | string | Routing rule identifier. (example: a7e6fb77503c41d8a7f3113c6918f10c) |
name | string | Routing rule name. (example: Send to user@example.net rule.) |
actions | array | List actions patterns. |
enabled | boolean | Routing rule status. (true, false) |
matchers | array | Matching patterns to forward to your actions. |
priority | number | Priority of the routing rule. |
tag | string | Routing rule tag. (Deprecated, replaced by routing rule identifier) (example: a7e6fb77503c41d8a7f3113c6918f10c) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | rule_identifier, zone_id | Get information for a specific routing rule already created. | |
list | select | zone_id | page, per_page, enabled | Lists existing routing rules. |
create | insert | zone_id, actions, matchers | 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. | |
update | replace | rule_identifier, zone_id, actions, matchers | Update actions and matches, or enable/disable specific routing rules. Forward actions require all destination addresses to be verified. | |
delete | delete | rule_identifier, zone_id | Delete 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.
| Name | Datatype | Description |
|---|---|---|
rule_identifier | string | |
zone_id | string | The Cloudflare zone ID. |
enabled | boolean | |
page | number | |
per_page | number |
SELECT examples
- get
- list
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
;
Lists existing routing rules.
SELECT
id,
name,
actions,
enabled,
matchers,
priority,
tag
FROM cloudflare.email_routing.rules
WHERE zone_id = '{{ zone_id }}' -- required
AND page = '{{ page }}'
AND per_page = '{{ per_page }}'
AND enabled = '{{ enabled }}'
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: rules
props:
- name: zone_id
value: "{{ zone_id }}"
description: Required parameter for the rules resource.
- name: actions
description: |
List actions patterns.
value:
- type: "{{ type }}"
value: "{{ value }}"
- name: enabled
value: {{ enabled }}
description: |
Routing rule status.
valid_values: ['true', 'false']
default: true
- name: matchers
description: |
Matching patterns to forward to your actions.
value:
- field: "{{ field }}"
type: "{{ type }}"
value: "{{ value }}"
- name: name
value: "{{ name }}"
description: |
Routing rule name.
- name: priority
value: {{ priority }}
description: |
Priority of the routing rule.
default: 0
REPLACE examples
- update
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
Delete a specific routing rule.
DELETE FROM cloudflare.email_routing.rules
WHERE rule_identifier = '{{ rule_identifier }}' --required
AND zone_id = '{{ zone_id }}' --required
;