PHP Client for Cloudflare API
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.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
paramsarrayNo[]Query Parameters: `description`, `user_agent`, `paused`, `page` and `per_page`.
php
$response = $client->firewall()->uaRules()->list('ZONE_ID', []);
View this operation on the Cloudflare API Reference

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',
]);
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
valuesarrayYes`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', []);
View this operation on the Cloudflare API Reference

Get

Fetch the details of a User Agent Blocking rule.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
ruleIdstringYesUser Agent Blocking rule Identifier.
php
$response = $client->firewall()->uaRules()->get('ZONE_ID', 'RULE_ID');
View this operation on the Cloudflare API Reference

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.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
ruleIdstringYesUser Agent Blocking rule Identifier.
valuesarrayYes`mode` and `configuration` are required, with `description` and `paused` optional.
php
$response = $client->firewall()->uaRules()->update('ZONE_ID', 'RULE_ID', []);
View this operation on the Cloudflare API Reference

Delete

Delete an existing User Agent Blocking rule.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
ruleIdstringYesUser Agent Blocking rule Identifier.
php
$response = $client->firewall()->uaRules()->delete('ZONE_ID', 'RULE_ID');
View this operation on the Cloudflare API Reference
Copyright © 2026