Delete a rule in a ruleset
Last updated Apr 16, 2026 Deletes a single rule in a ruleset at the account or zone level.
Use one of the following API endpoints:
- Delete an account ruleset rule
DELETE /accounts/{account_id}/rulesets/{ruleset_id}/rules/{rule_id} - Delete a zone ruleset rule
DELETE /zones/{zone_id}/rulesets/{ruleset_id}/rules/{rule_id}
If the delete operation succeeds, the API method call returns a 200 OK HTTP status code with the complete ruleset in the response body.
Example
The following example deletes rule $RULE_ID_1 belonging to ruleset $RULESET_ID.
The response will include the complete ruleset after deleting the rule.
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Mass URL Redirects Write</code>
- <code>Magic Firewall Write</code>
- <code>L4 DDoS Managed Ruleset Write</code>
- <code>Transform Rules Write</code>
- <code>Select Configuration Write</code>
- <code>Account WAF Write</code>
- <code>Account Rulesets Write</code>
- <code>Logs Write</code>
</details>
Delete an account ruleset rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rulesets/$RULESET_ID/rules/$RULE_ID_1" \
--request DELETE \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
"result": {
"id": "<RULESET_ID>",
"name": "Custom Ruleset 1",
"description": "My first custom ruleset",
"kind": "custom",
"version": "12",
"rules": [
{
"id": "<RULE_ID_2>",
"version": "2",
"action": "js_challenge",
"expression": "(ip.src.country in {\"GB\" \"FR\"} and cf.bot_management.score < 20 and not cf.bot_management.verified_bot)",
"description": "challenge GB and FR based on bot score",
"last_updated": "2021-07-22T12:54:58.144683Z",
"ref": "<RULE_REF_2>",
"enabled": true
}
],
"last_updated": "2021-07-22T12:54:58.144683Z",
"phase": "http_request_firewall_custom"
},
"success": true,
"errors": [],
"messages": []
}
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ruleset-engine/rulesets-api/delete-rule/#page","headline":"Delete a rule in a ruleset","description":"Delete a specific rule from a ruleset using the API.","url":"https://developers.cloudflare.com/ruleset-engine/rulesets-api/delete-rule/","inLanguage":"en","image":"https://developers.cloudflare.com/ruleset-engine/rulesets-api/delete-rule/og.png?v=72c8c0e768e87bb9","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Validate rules and rulesets in the Cloudflare dashboard or with the Rulesets API without deploying changes. title: Validate rule changes before deployment image: https://developers.cloudflare.com/ruleset-engine/rulesets-api/dry-run/og.png?v=743eb1fcf2f86071
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/ruleset-engine/llms.txt
Use this file to discover all available pages before exploring further.
Docs