Skip to main content
The Firewall resource provides methods to manage firewall rules, access rules, lockdowns, user agent rules, and Web Application Firewall (WAF) settings.

Firewall rules

create

Create one or more firewall rules.
string
required
Zone identifier
array
required
Array of firewall rules to create
object
required
Filter expression
string
required
Firewall filter expression (e.g., ‘(http.request.uri.path contains “/api/”)’)
'block' | 'challenge' | 'js_challenge' | 'managed_challenge' | 'allow' | 'log' | 'bypass'
required
Action to perform when the rule matches
string
Description of the rule
number
Rule priority (lower numbers execute first)
boolean
Whether the rule is paused
string
Firewall rule identifier
object
Filter configuration
string
Action to perform
string
Rule description
number
Rule priority
boolean
Whether the rule is paused

update

Update a firewall rule.
string
required
Firewall rule identifier (first parameter)
string
required
Zone identifier

list

List all firewall rules for a zone.
string
required
Zone identifier

delete

Delete a firewall rule.
string
required
Firewall rule identifier (first parameter)
string
required
Zone identifier

get

Get details for a specific firewall rule.

Access rules

Access rules allow you to block, challenge, or allow traffic based on IP address, IP range, country, or ASN.

create

Create an access rule.
string
Account identifier (use either account_id or zone_id)
string
Zone identifier (use either account_id or zone_id)
'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'
required
Action to apply to matching traffic
object
required
Rule configuration
'ip' | 'ip_range' | 'country' | 'asn' | 'ip6'
required
Target type
string
required
Target value (IP address, country code, ASN number, etc.)
string
Description or notes about the rule

list

List access rules.
string
Filter by mode
string
Filter by target type

Lockdowns

Lockdowns restrict access to URLs to specific IP addresses or ranges.

create

Create a zone lockdown rule.
string
required
Zone identifier
string[]
required
URLs to apply the lockdown to (supports wildcards)
array
required
IP addresses or ranges to allow
'ip' | 'ip_range'
required
Configuration type
string
required
IP address or CIDR range
string
Description of the lockdown
boolean
Whether the lockdown is paused

list

List zone lockdown rules.

User agent rules

User agent rules allow you to block or challenge requests based on the User-Agent header.

create

Create a user agent blocking rule.
string
required
Zone identifier
'block' | 'challenge' | 'js_challenge' | 'managed_challenge'
required
Action to apply
object
required
Configuration
'ua'
required
Must be ‘ua’
string
required
User agent string to match

Firewall actions

Available actions for firewall rules:
  • block - Block the request
  • challenge - Present a CAPTCHA challenge
  • js_challenge - Present a JavaScript challenge
  • managed_challenge - Present a Cloudflare-managed challenge
  • allow - Allow the request
  • log - Log the request but take no action
  • bypass - Bypass subsequent firewall rules

Example usage