Skip to content

Update or deploy a ruleset

Last updated View as MarkdownAgent setup

Use one of the following API endpoints to update a ruleset:

When updating a ruleset, you can update:

  • The basic properties of a ruleset (currently only the description)
  • The list of rules in a ruleset

You cannot update the name of the ruleset or its type. Do not include these fields in the data field of your PUT request.

To deploy a ruleset, add a rule with "action": "execute" to the list of rules of an entry point ruleset. Refer to Deploy a ruleset for an example.

Example - Set the rules of a ruleset

The following PUT request defines the list of rules of a ruleset, setting it to a single rule. You must include all the rules you want to associate with the ruleset in every request.

Required API token permissions

At least one of the following token permissions is required:
  • Response Compression Write
  • Config Settings Write
  • Dynamic URL Redirects Write
  • Cache Settings Write
  • Custom Errors Write
  • Origin Write
  • Managed headers Write
  • Zone Transform Rules Write
  • Mass URL Redirects Write
  • Magic Firewall Write
  • L4 DDoS Managed Ruleset Write
  • HTTP DDoS Managed Ruleset Write
  • Sanitize Write
  • Transform Rules Write
  • Select Configuration Write
  • Bot Management Write
  • Zone WAF Write
  • Account WAF Write
  • Account Rulesets Write
  • Logs Write
  • Logs Write
Update a zone rulesetbash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/$RULESET_ID" \
	--request PUT \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"rules": [
				{
						"action": "execute",
						"action_parameters": {
								"id": "<MANAGED_RULESET_ID>"
						},
						"expression": "true"
				}
		]
	}'
{
	"result": {
		"id": "<RULESET_ID>",
		"name": "Zone-level phase entry point ruleset",
		"description": "This ruleset executes a managed ruleset.",
		"kind": "zone",
		"version": "4",
		"rules": [
			{
				"id": "<RULE_ID>",
				"version": "2",
				"action": "execute",
				"expression": "true",
				"action_parameters": {
					"id": "<MANAGED_RULESET_ID>"
				},
				"last_updated": "2025-03-17T15:42:37.917815Z"
			}
		],
		"last_updated": "2025-03-17T15:42:37.917815Z",
		"phase": "http_request_firewall_managed"
	},
	"success": true,
	"errors": [],
	"messages": []
}

Example - Deploy a ruleset

To deploy a ruleset, create a rule with "action": "execute" that executes the ruleset, and add the ruleset ID to the action_parameters field in the id