Skip to main content

access_rules

Creates, updates, deletes, gets or lists an access_rules resource.

Overview

Nameaccess_rules
TypeResource
Idcloudflare.firewall.access_rules

Fields

The following fields are returned by SELECT queries:

Get an IP Access rule response.

NameDatatypeDescription
idstringThe unique identifier of the IP Access rule. (example: 92f17202ed8bd63d69a66b86a49a8f6b)
allowed_modesarrayThe available actions that a rule can apply to a matched request.
configurationobjectThe rule configuration. (title: An IP address configuration.)
created_onstring (date-time)The timestamp of when the rule was created. (example: 2014-01-01T05:20:00.12345Z)
modestringThe action to apply to a matched request. (block, challenge, whitelist, js_challenge, managed_challenge) (example: challenge)
modified_onstring (date-time)The timestamp of when the rule was last modified. (example: 2014-01-01T05:20:00.12345Z)
notesstringAn informative summary of the rule, typically used as a reminder or explanation. (example: This rule is enabled because of an event that occurred on date X.)
scopeobjectAll zones owned by the user will have the rule applied.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_by_accountselectrule_id, account_idFetches the details of an IP Access rule defined.
get_by_zoneselectrule_id, zone_idFetches the details of an IP Access rule defined.
list_by_accountselectaccount_idmode, configuration.target, configuration.value, notes, match, page, per_page, order, directionFetches IP Access rules of an account or zone. These rules apply to all the zones in the account or zone. You can filter the results using several optional parameters.
list_by_zoneselectzone_idmode, configuration.target, configuration.value, notes, match, page, per_page, order, directionFetches IP Access rules of an account or zone. These rules apply to all the zones in the account or zone. You can filter the results using several optional parameters.
create_by_accountinsertaccount_id, mode, configurationCreates a new IP Access rule for an account or zone. The rule will apply to all zones in the account or zone. Note: To create an IP Access rule that applies to a single zone, refer to the IP Access rules for a zone endpoints.
create_by_zoneinsertzone_id, mode, configurationCreates a new IP Access rule for an account or zone. The rule will apply to all zones in the account or zone. Note: To create an IP Access rule that applies to a single zone, refer to the IP Access rules for a zone endpoints.
edit_by_accountupdaterule_id, account_id, mode, configurationUpdates an IP Access rule defined. Note: This operation will affect all zones in the account or zone.
edit_by_zoneupdaterule_id, zone_id, mode, configurationUpdates an IP Access rule defined. Note: This operation will affect all zones in the account or zone.
delete_by_accountdeleterule_id, account_idDeletes an existing IP Access rule defined. Note: This operation will affect all zones in the account or zone.
delete_by_zonedeleterule_id, zone_idDeletes an existing IP Access rule defined. Note: This operation will affect all zones in the account or zone.

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.
zone_idstringThe Cloudflare zone ID.
configuration.targetstring
configuration.valuestring
directionstring
matchstring
modestring
notesstring
orderstring
pagenumber
per_pagenumber

SELECT examples

Fetches the details of an IP Access rule defined.

SELECT
id,
allowed_modes,
configuration,
created_on,
mode,
modified_on,
notes,
scope
FROM cloudflare.firewall.access_rules
WHERE rule_id = '{{ rule_id }}' -- required
AND account_id = '{{ account_id }}' -- required
;

INSERT examples

Creates a new IP Access rule for an account or zone. The rule will apply to all zones in the account or zone. Note: To create an IP Access rule that applies to a single zone, refer to the IP Access rules for a zone endpoints.

INSERT INTO cloudflare.firewall.access_rules (
configuration,
mode,
notes,
account_id
)
SELECT
'{{ configuration }}' /* required */,
'{{ mode }}' /* required */,
'{{ notes }}',
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Updates an IP Access rule defined. Note: This operation will affect all zones in the account or zone.

UPDATE cloudflare.firewall.access_rules
SET
configuration = '{{ configuration }}',
mode = '{{ mode }}',
notes = '{{ notes }}'
WHERE
rule_id = '{{ rule_id }}' --required
AND account_id = '{{ account_id }}' --required
AND mode = '{{ mode }}' --required
AND configuration = '{{ configuration }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Deletes an existing IP Access rule defined. Note: This operation will affect all zones in the account or zone.

DELETE FROM cloudflare.firewall.access_rules
WHERE rule_id = '{{ rule_id }}' --required
AND account_id = '{{ account_id }}' --required
;