To invoke a Cloudflare Firewall Rules API operation, append the endpoint to the Cloudflare API base URL (https://api.cloudflare.com/client/v4/zones/{zone_id}). For authentication instructions, consult the standard Cloudflare API documentation.

The Cloudflare Firewall Rules API endpoints are:

Method + URL stub Description Notes
POST /firewall/rules - Create one or more rules
- See POST example call
- Handled as a single transaction
- If one fails, then all fail
GET /firewall/rules - Fetch rules
- See GET example call
- Query on (case-insensitive):
   - Exact match for one or more id
   - Text in the description value
   - Exact match on one or more ref

- Results paginated (25-item default)*

- No query returns all active and paused rules
GET /firewall/rules/{id} - Fetch a rule by ID
- See GET example call
PUT /firewall/rules - Update rules
- See PUT example call
- Handled as a single transaction
- All rules must exist
- If one fails, all updates fail
PUT /firewall/rules/{id} - Update a rule by ID
- See PUT example call
DELETE /firewall/rules - Delete rules
- See DELETE example calls
- Must be specified with list of identifiers returned by GET
- Empty input results in no deletion
- Returns 200 if rule does not exist
DELETE /firewall/rules/{id} - Delete a rule by ID
- See DELETE example call
* To learn how to page through results, see Requests > Pagination in Cloudflare API Getting Started.