WAF managed rules upgrade·续2
API operations
Upgrading to the new WAF Managed Rules via API requires invoking the following API operations:
| Name | Method + Endpoint | Description |
|---|---|---|
| Check WAF<br>update compatibility | GET /zones/<ZONE_ID>/waf_migration/check?phase_two=1 |
Checks if the current zone can be updated to the new WAF, given its current configuration. |
| Get new WAF<br>configuration | GET /zones/<ZONE_ID>/waf_migration/config?phase_two=1 |
Obtains the new WAF Managed Rules configuration that is equivalent to the current configuration (previous version of WAF managed rules). |
| Update zone<br>entry point ruleset | PUT /zones/<ZONE_ID>/rulesets/ phases/http_request_firewall_managed/entrypoint?waf_migration=<VALUE>&phase_two=1 |
Updates the configuration of the zone entry point ruleset for the http_request_firewall_managed phase.<br>Available values for the waf_migration query string parameter:<br>– pending / 1: Defines the new WAF Managed Rules configuration and disables the previous version of WAF managed rules as soon as the provided configuration is saved and the new WAF is enabled.<br>– validation / 2: (Enterprise zones only) Defines the new WAF Managed Rules configuration and enables the new WAF Managed Rules side by side with the previous version, entering validation mode. To exit validation mode and finish the upgrade, invoke the same API endpoint with waf_migration=pending. |
| Get WAF status | GET /zones/<ZONE_ID>/waf_migration/status |
Obtains the status of old and new WAF managed rules for a zone (enabled/disabled). The response also includes the current upgrade state (or mode). |
You must prepend the Cloudflare API base URL to the endpoints listed above to obtain the full endpoint:
https://api.cloudflare.com/client/v4
Possible upgrade errors
Contact Cloudflare Support to get help with the following errors:
- The number of firewall rules to migrate exceeds 200.
- The length of a firewall rule expression is longer than 4 KB.
Additional resources
Configuring the new WAF Managed Rules using the Cloudflare API
Instead of using the previous APIs for managing WAF packages, rule groups, and rules, you must now use the Rulesets API to programmatically configure WAF Managed Rules.
You can also create overrides to specify changes to be executed on top of the default WAF Managed Rules configuration. These changes will take precedence over the managed ruleset’s default behavior.
For more information, refer to the following resources:
Configuring the new WAF Managed Rules using Terraform
Instead of using the previous resources for managing WAF packages, rule groups, and rules, you must now use the cloudflare_ruleset ↗︎ Terraform resource to configure WAF Managed Rules. For configuration examples, refer to WAF Managed Rules configuration using Terraform.
Replace your configuration using cf-terraforming
You can use the cf-terraforming ↗︎ tool to generate the Terraform configuration for your new WAF Managed Rules configuration after you upgrade. Then, import the new resources to Terraform state.
The recommended steps for replacing your old WAF managed rules configuration in Terraform with a new ruleset-based configuration for the new WAF Managed Rules are the following:
- Run the following command to generate all ruleset configurations for a zone:
cf-terraforming generate --zone <ZONE_ID> --resource-type "cloudflare_ruleset"
```
```txt
resource "cloudflare_ruleset" "terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31" {
kind = "zone"
name = "default"
phase = "http_request_firewall_managed"
zone_id = "<ZONE_ID>"
rules {
[...]
}
[...]
}
[...]
```
2. The previous command may return additional ruleset configurations for other Cloudflare products also based on the [Ruleset Engine](https://developers.cloudflare.com/ruleset-engine/). Since you are looking for the WAF Managed Rules configuration, keep only the Terraform resource for the `http_request_firewall_managed` phase and save it to a `.tf` configuration file. You will need the full resource name in the next step.
3. Import the `cloudflare_ruleset` resource you previously identified into Terraform state using the `terraform import` command. For example:
```sh
terraform import cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31 zone/<ZONE_ID>/3c0b456bc2aa443089c5f40f45f51b31
```
```txt
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Importing from ID "zone/<ZONE_ID>/3c0b456bc2aa443089c5f40f45f51b31"...
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Import prepared!
Prepared cloudflare_ruleset for import
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Refreshing state... [id=3c0b456bc2aa443089c5f40f45f51b31]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
```
4. Run `terraform plan` to validate that Terraform now checks the state of the new `cloudflare_ruleset` resource, in addition to other existing resources already managed by Terraform. For example:
```sh
terraform plan
```
```txt
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Refreshing state... [id=3c0b456bc2aa443089c5f40f45f51b31]
[...]
cloudflare_waf_package.my_package: Refreshing state... [id=14a2524fd75c419f8d273116815b6349]
cloudflare_waf_group.my_group: Refreshing state... [id=0580eb5d92e344ddb2374979f74c3ddf]
[...]
```
5. Remove any state related to the previous version of WAF managed rules from your Terraform state:
Caution
You must remove WAF packages, groups, and rules from Terraform state before deleting their configuration from `.tf` configuration files to prevent issues.
1. Run the following command to find all resources related to the previous version of WAF managed rules:
```sh
terraform state list | grep -E '^cloudflare_waf_(package|group|rule)\.'
```
```txt
cloudflare_waf_package.my_package
cloudflare_waf_group.my_group
```
2. Run the `terraform state rm ...` command in dry-run mode to understand the impact of removing those resources without performing any changes:
```sh
terraform state rm -dry-run cloudflare_waf_package.my_package cloudflare_waf_group.my_group
```
```txt
Would remove cloudflare_waf_package.my_package
Would remove cloudflare_waf_group.my_group
```
3. If the impact looks correct, run the same command without the `-dry-run` parameter to actually remove the resources from Terraform state:
```sh
terraform state rm cloudflare_waf_package.my_package cloudflare_waf_group.my_group
```
```txt
Removed cloudflare_waf_package.my_package
Removed cloudflare_waf_group.my_group
Successfully removed 2 resource instance(s).
```
6. After removing WAF package, group, and rule resources from Terraform state, delete `cloudflare_waf_package`, `cloudflare_waf_group`, and `cloudflare_waf_rule` resources from `.tf` configuration files.
7. Run `terraform plan` to verify that the resources you deleted from configuration files no longer appear. You should not have any pending changes.
```sh
terraform plan
```
```txt
cloudflare_ruleset.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Refreshing state... [id=3c0b456bc2aa443089c5f40f45f51b31]
[...]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
```
For details on importing Cloudflare resources to Terraform and using the `cf-terraforming` tool, refer to the following resources:
- [Import Cloudflare resources](https://developers.cloudflare.com/terraform/advanced-topics/import-cloudflare-resources/)
- [`cf-terraforming` GitHub repository ↗︎](https://github.com/cloudflare/cf-terraforming)
---
## Final remarks
The concept of paranoia level did not exist in the OWASP version (2.x) used in WAF managed rules. Based on the OWASP guide recommendations, the WAF migration process will set the paranoia level of the Cloudflare OWASP Core Ruleset to *PL2*.
You cannot disable the new version of WAF Managed Rules using [Page Rules](https://developers.cloudflare.com/rules/page-rules/), since the *Web Application Firewall: Off* setting in Page Rules only applies to the previous version of WAF managed rules. To disable the new WAF Managed Rules you must configure [exceptions](https://developers.cloudflare.com/waf/managed-rules/waf-exceptions/) (also known as skip rules).
Was this helpful?
YesNo
## On this page
[Docs](https://developers.cloudflare.com/)
```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/upgrade/#page","headline":"WAF managed rules upgrade","description":"Upgrade from the previous version of WAF managed rules.","url":"https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/upgrade/","inLanguage":"en","image":"https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/upgrade/og.png?v=9c4a902247d21ca5","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: WAF rule execution phases and their order of evaluation. title: WAF phases image: https://developers.cloudflare.com/waf/reference/phases/og.png?v=3bb798deab615a01
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.
