Firewall
UA Rules
User Agent Blocking rules: match requests by their `User-Agent` header and act on them, per zone.
User Agent Blocking rules: match requests by their User-Agent header and
act on them, per zone.
List
Fetch User Agent Blocking rules in a zone.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
zoneId | string | Yes | Zone Identifier. | |
params | array | No | [] | Query Parameters: `description`, `user_agent`, `paused`, `page` and `per_page`. |
php
$response = $client->firewall()->uaRules()->list('ZONE_ID', []);
Create
Create a new User Agent Blocking rule in a zone.
$client->firewall()->uaRules()->create('ZONE_ID', [
'mode' => 'block',
'configuration' => ['target' => 'ua', 'value' => 'BadCrawler/1.0'],
'description' => 'Block a misbehaving crawler',
]);
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
zoneId | string | Yes | Zone Identifier. | |
values | array | Yes | `mode`, one of `block`, `challenge`, `whitelist`, `js_challenge` or `managed_challenge`, and `configuration` with its `target` and `value`. `description` and `paused` are optional. |
php
$response = $client->firewall()->uaRules()->create('ZONE_ID', []);
Get
Fetch the details of a User Agent Blocking rule.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
zoneId | string | Yes | Zone Identifier. | |
ruleId | string | Yes | User Agent Blocking rule Identifier. |
php
$response = $client->firewall()->uaRules()->get('ZONE_ID', 'RULE_ID');
Update
Update an existing User Agent Blocking rule, overwriting the full configuration.
Cloudflare wants the rule's id in the body as well as in the path, so
it is filled in from $ruleId unless $values carries one already.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
zoneId | string | Yes | Zone Identifier. | |
ruleId | string | Yes | User Agent Blocking rule Identifier. | |
values | array | Yes | `mode` and `configuration` are required, with `description` and `paused` optional. |
php
$response = $client->firewall()->uaRules()->update('ZONE_ID', 'RULE_ID', []);
Delete
Delete an existing User Agent Blocking rule.
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
zoneId | string | Yes | Zone Identifier. | |
ruleId | string | Yes | User Agent Blocking rule Identifier. |
php
$response = $client->firewall()->uaRules()->delete('ZONE_ID', 'RULE_ID');

