Cloudflare Managed Ruleset·续
Configure via API
To deploy the Cloudflare Managed Ruleset for a given zone via API, create a rule with execute action in the entry point ruleset for the http_request_firewall_managed phase.
Example
The following example deploys the Cloudflare Managed Ruleset to the http_request_firewall_managed phase of a given zone ($ZONE_ID) by creating a rule that executes the managed ruleset.
- Invoke the Get a zone entry point ruleset operation to obtain the definition of the entry point ruleset for the
http_request_firewall_managedphase. You will need the zone ID for this task.
Get a zone entry point rulesetbash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/http_request_firewall_managed/entrypoint" \
--request GET \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
```
```json
{
"result": {
"description": "Zone-level phase entry point",
"id": "<RULESET_ID>",
"kind": "zone",
"last_updated": "2024-03-16T15:40:08.202335Z",
"name": "zone",
"phase": "http_request_firewall_managed",
"rules": [
// ...
],
"source": "firewall_managed",
"version": "10"
},
"success": true,
"errors": [],
"messages": []
}
```
2. If the entry point ruleset already exists (that is, if you received a `200 OK` status code and the ruleset definition), take note of the ruleset ID in the response. Then, invoke the [Create a zone ruleset rule](https://developers.cloudflare.com/api/resources/rulesets/subresources/rules/methods/create/) operation to add an `execute` rule to the existing ruleset deploying the Cloudflare Managed Ruleset (with ID `efb7b8c949ac4650a09736fc376e9aee`). By default, the rule will be added at the end of the list of rules already in the ruleset.
*Create a zone ruleset rulebash*
```bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/$RULESET_ID/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"action": "execute",
"action_parameters": {
"id": "efb7b8c949ac4650a09736fc376e9aee"
},
"expression": "true",
"description": "Execute the Cloudflare Managed Ruleset"
}'
```
```json
{
"result": {
"id": "<RULESET_ID>",
"name": "Zone-level phase entry point",
"description": "",
"kind": "zone",
"version": "11",
"rules": [
// ... any existing rules
{
"id": "<RULE_ID>",
"version": "1",
"action": "execute",
"action_parameters": {
"id": "efb7b8c949ac4650a09736fc376e9aee",
"version": "latest"
},
"expression": "true",
"description": "Execute the Cloudflare Managed Ruleset",
"last_updated": "2024-03-18T18:08:14.003361Z",
"ref": "<RULE_REF>",
"enabled": true
}
],
"last_updated": "2024-03-18T18:08:14.003361Z",
"phase": "http_request_firewall_managed"
},
"success": true,
"errors": [],
"messages": []
}
```
3. If the entry point ruleset does not exist (that is, if you received a `404 Not Found` status code in step 1), create it using the [Create a zone ruleset](https://developers.cloudflare.com/api/resources/rulesets/methods/create/) operation. Include a single rule in the `rules` array that executes the Cloudflare Managed Ruleset (with ID `efb7b8c949ac4650a09736fc376e9aee`) for all incoming requests in the zone.
*Create a zone rulesetbash*
```bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "My ruleset",
"description": "Entry point ruleset for WAF managed rulesets",
"kind": "zone",
"phase": "http_request_firewall_managed",
"rules": [
{
"action": "execute",
"action_parameters": {
"id": "efb7b8c949ac4650a09736fc376e9aee"
},
"expression": "true",
"description": "Execute the Cloudflare Managed Ruleset"
}
]
}'
```
### Next steps
To configure the Cloudflare Managed Ruleset via API, create [overrides](https://developers.cloudflare.com/ruleset-engine/managed-rulesets/override-managed-ruleset/) using the Rulesets API. You can perform the following configurations:
- Specify the action to perform for all the rules in the ruleset by creating a ruleset override.
- Disable or customize the action of individual rules by creating rule overrides.
For examples of creating overrides using the API, refer to [Override a managed ruleset](https://developers.cloudflare.com/ruleset-engine/managed-rulesets/override-managed-ruleset/).
### More resources
For more information on working with managed rulesets via API, refer to [Work with managed rulesets](https://developers.cloudflare.com/ruleset-engine/managed-rulesets/) in the Ruleset Engine documentation.
## Configure using Terraform
The following example deploys the Cloudflare Managed Ruleset for a zone and overrides the action and status of a specific 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>Zone WAF Write</code>
</details>
Configure the [`cloudflare_ruleset` ↗︎](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/ruleset) resource:
```tf
# Configure a ruleset at the zone level for the "http_request_firewall_managed" phase
resource "cloudflare_ruleset" "zone_level_managed_waf" {
zone_id = var.cloudflare_zone_id
name = "Managed WAF entry point ruleset"
description = "Zone-level WAF Managed Rules config"
kind = "zone"
phase = "http_request_firewall_managed"
# Execute Cloudflare Managed Ruleset
rules = [{
ref = "execute_cloudflare_managed_ruleset"
description = "Execute Cloudflare Managed Ruleset on my zone-level phase entry point ruleset"
expression = "true"
action = "execute"
action_parameters = {
id = "efb7b8c949ac4650a09736fc376e9aee"
overrides = {
rules = [{
id = "5de7edfa648c4d6891dc3e7f84534ffa"
action = "log"
enabled = true
}]
}
}
}]
}
# Configure a ruleset at the zone level for the "http_request_firewall_managed" phase
resource "cloudflare_ruleset" "zone_level_managed_waf" {
zone_id = var.cloudflare_zone_id
name = "Managed WAF entry point ruleset"
description = "Zone-level WAF Managed Rules config"
kind = "zone"
phase = "http_request_firewall_managed"
# Execute Cloudflare Managed Ruleset
rules {
ref = "execute_cloudflare_managed_ruleset"
description = "Execute Cloudflare Managed Ruleset on my zone-level phase entry point ruleset"
expression = "true"
action = "execute"
action_parameters {
id = "efb7b8c949ac4650a09736fc376e9aee"
overrides {
rules {
id = "5de7edfa648c4d6891dc3e7f84534ffa"
action = "log"
enabled = true
}
}
}
}
}
For more information, refer to WAF Managed Rules configuration using Terraform.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/waf/managed-rules/reference/cloudflare-managed-ruleset/#page","headline":"Cloudflare Managed Ruleset","description":"Rules and categories in the Cloudflare Managed Ruleset.","url":"https://developers.cloudflare.com/waf/managed-rules/reference/cloudflare-managed-ruleset/","inLanguage":"en","image":"https://developers.cloudflare.com/waf/managed-rules/reference/cloudflare-managed-ruleset/og.png?v=696098f08fdf279a","dateModified":"2026-08-25","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: Rules in the Cloudflare Exposed Credentials Check managed ruleset. title: Cloudflare Exposed Credentials Check Managed Ruleset image: https://developers.cloudflare.com/waf/managed-rules/reference/exposed-credentials-check/og.png?v=a32232d0f5514b8f
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/waf/llms.txt
Use this file to discover all available pages before exploring further.
Docs