Skip to main content

rules

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

Overview

Namerules
TypeResource
Idcloudflare.rulesets.rules

Fields

The following fields are returned by SELECT queries:

SELECT not supported for this resource, use SHOW METHODS to view available operations for the resource.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
create_by_accountinsertruleset_id, account_idAdds a new rule to an account or zone ruleset. The rule will be added to the end of the existing list of rules in the ruleset by default.
create_by_zoneinsertruleset_id, zone_idAdds a new rule to an account or zone ruleset. The rule will be added to the end of the existing list of rules in the ruleset by default.
edit_by_accountupdaterule_id, ruleset_id, account_idUpdates an existing rule in an account or zone ruleset.
edit_by_zoneupdaterule_id, ruleset_id, zone_idUpdates an existing rule in an account or zone ruleset.
delete_by_accountdeleterule_id, ruleset_id, account_idDeletes an existing rule from an account or zone ruleset.
delete_by_zonedeleterule_id, ruleset_id, zone_idDeletes an existing rule from an account or zone ruleset.

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
account_idstringThe Cloudflare account ID.
rule_idstringThe rule ID.
ruleset_idstringThe ruleset ID.
zone_idstringThe Cloudflare zone ID.

INSERT examples

Adds a new rule to an account or zone ruleset. The rule will be added to the end of the existing list of rules in the ruleset by default.

INSERT INTO cloudflare.rulesets.rules (
position,
action,
action_parameters,
description,
enabled,
exposed_credential_check,
expression,
id,
logging,
ratelimit,
ref,
ruleset_id,
account_id
)
SELECT
'{{ position }}',
'{{ action }}',
'{{ action_parameters }}',
'{{ description }}',
{{ enabled }},
'{{ exposed_credential_check }}',
'{{ expression }}',
'{{ id }}',
'{{ logging }}',
'{{ ratelimit }}',
'{{ ref }}',
'{{ ruleset_id }}',
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Updates an existing rule in an account or zone ruleset.

UPDATE cloudflare.rulesets.rules
SET
position = '{{ position }}',
action = '{{ action }}',
action_parameters = '{{ action_parameters }}',
description = '{{ description }}',
enabled = {{ enabled }},
exposed_credential_check = '{{ exposed_credential_check }}',
expression = '{{ expression }}',
id = '{{ id }}',
logging = '{{ logging }}',
ratelimit = '{{ ratelimit }}',
ref = '{{ ref }}'
WHERE
rule_id = '{{ rule_id }}' --required
AND ruleset_id = '{{ ruleset_id }}' --required
AND account_id = '{{ account_id }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Deletes an existing rule from an account or zone ruleset.

DELETE FROM cloudflare.rulesets.rules
WHERE rule_id = '{{ rule_id }}' --required
AND ruleset_id = '{{ ruleset_id }}' --required
AND account_id = '{{ account_id }}' --required
;