Skip to main content

ua_rules

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

Overview

Nameua_rules
TypeResource
Idcloudflare.firewall.ua_rules

Fields

The following fields are returned by SELECT queries:

Get a User Agent Blocking rule response

NameDatatypeDescription
idstringThe unique identifier of the User Agent Blocking rule. (example: 372e67954025e0ba6aaa6d586b9e0b59)
configurationobjectThe configuration object for the current rule.
descriptionstringAn informative summary of the rule. (example: Prevent access from abusive clients identified by this User Agent to mitigate a DDoS attack)
modestringThe action to apply to a matched request. (block, challenge, js_challenge, managed_challenge) (example: js_challenge)
pausedbooleanWhen true, indicates that the rule is currently paused.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectua_rule_id, zone_idFetches the details of a User Agent Blocking rule.
listselectzone_idpage, description, per_page, user_agent, pausedFetches User Agent Blocking rules in a zone. You can filter the results using several optional parameters.
createinsertzone_id, mode, configurationCreates a new User Agent Blocking rule in a zone.
updatereplaceua_rule_id, zone_id, mode, configurationUpdates an existing User Agent Blocking rule.
deletedeleteua_rule_id, zone_idDeletes an existing User Agent Blocking 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
ua_rule_idstring
zone_idstringThe Cloudflare zone ID.
descriptionstring
pagenumber
pausedboolean
per_pagenumber
user_agentstring

SELECT examples

Fetches the details of a User Agent Blocking rule.

SELECT
id,
configuration,
description,
mode,
paused
FROM cloudflare.firewall.ua_rules
WHERE ua_rule_id = '{{ ua_rule_id }}' -- required
AND zone_id = '{{ zone_id }}' -- required
;

INSERT examples

Creates a new User Agent Blocking rule in a zone.

INSERT INTO cloudflare.firewall.ua_rules (
configuration,
description,
mode,
paused,
zone_id
)
SELECT
'{{ configuration }}' /* required */,
'{{ description }}',
'{{ mode }}' /* required */,
{{ paused }},
'{{ zone_id }}'
RETURNING
errors,
messages,
result,
success
;

REPLACE examples

Updates an existing User Agent Blocking rule.

REPLACE cloudflare.firewall.ua_rules
SET
configuration = '{{ configuration }}',
description = '{{ description }}',
mode = '{{ mode }}',
paused = {{ paused }}
WHERE
ua_rule_id = '{{ ua_rule_id }}' --required
AND zone_id = '{{ zone_id }}' --required
AND mode = '{{ mode }}' --required
AND configuration = '{{ configuration }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Deletes an existing User Agent Blocking rule.

DELETE FROM cloudflare.firewall.ua_rules
WHERE ua_rule_id = '{{ ua_rule_id }}' --required
AND zone_id = '{{ zone_id }}' --required
;