INTEGRITY Cloudflare Docs

Enable only selected rules

Use a ruleset override and a rule override in a phase entry point ruleset to execute only selected rules in a managed ruleset.

  1. Add a rule to a phase entry point ruleset that executes a managed ruleset.
  2. Configure a ruleset override that disables all rules in the managed ruleset.
  3. Configure a rule override to set an action for the rules you want to execute.

Zone-level example

The following PUT request uses the Update a zone entry point ruleset operation to define a configuration that executes only two rules from a managed ruleset in the http_request_firewall_managed phase.

In this example:

Required API token permissions

At least one of the following token permissions is required:
Update a zone entry point ruleset
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/http_request_firewall_managed/entrypoint" \
	--request PUT \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"rules": [
				{
						"action": "execute",
						"expression": "true",
						"action_parameters": {
								"id": "<MANAGED_RULESET_ID>",
								"overrides": {
										"enabled": false,
										"rules": [
												{
														"id": "<RULE_ID_1>",
														"action": "block",
														"enabled": true
												},
												{
														"id": "<RULE_ID_2>",
														"action": "log",
														"enabled": true
												}
										]
								}
						}
				}
		]
	}'

Account-level example

The following PUT request uses the Update an account entry point ruleset operation to define a configuration that executes only two rules from a managed ruleset in the http_request_firewall_managed phase.

In this example:

Required API token permissions

At least one of the following token permissions is required:
Update an account entry point ruleset
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rulesets/phases/http_request_firewall_managed/entrypoint" \
	--request PUT \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"rules": [
				{
						"action": "execute",
						"expression": "cf.zone.name eq \"example.com\" and cf.zone.plan eq \"ENT\"",
						"action_parameters": {
								"id": "<MANAGED_RULESET_ID>",
								"overrides": {
										"enabled": false,
										"rules": [
												{
														"id": "<RULE_ID_1>",
														"action": "block",
														"enabled": true
												},
												{
														"id": "<RULE_ID_2>",
														"action": "log",
														"enabled": true
												}
										]
								}
						}
				}
		]
	}'