---
description: Deploy WAF managed rulesets at the account level using the API.
title: Deploy a WAF managed ruleset via API (account)
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> 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.

# Deploy a WAF managed ruleset via API (account)

Last updated Aug 24, 2026|Copy as Markdown|[View as Markdown](https://e8aee267.previews.developers.cloudflare.com/waf/account/managed-rulesets/deploy-api/index.md)|[Agent setup](https://e8aee267.previews.developers.cloudflare.com/agent-setup/)

Note

This feature requires an Enterprise plan.

Use the [Rulesets API](https://e8aee267.previews.developers.cloudflare.com/ruleset-engine/rulesets-api/) to deploy a WAF managed ruleset to the `http_request_firewall_managed` phase at the account level.

The [WAF Managed Rules](https://e8aee267.previews.developers.cloudflare.com/waf/managed-rules/#available-managed-rulesets) page includes the IDs of the different WAF managed rulesets. You will need this information when deploying rulesets via API.

If you are using Terraform, refer to [WAF Managed Rules configuration using Terraform](https://e8aee267.previews.developers.cloudflare.com/terraform/additional-configurations/waf-managed-rulesets/#deploy-managed-rulesets-at-the-account-level).

## Example

The following example deploys the [Cloudflare Managed Ruleset](https://e8aee267.previews.developers.cloudflare.com/waf/managed-rules/reference/cloudflare-managed-ruleset/) to the `http_request_firewall_managed` phase of a given account (`$ACCOUNT_ID`) by creating a rule that executes the managed ruleset. The rules in the managed ruleset are executed when the zone name matches one of `example.com` or `anotherexample.com`.

1. Invoke the [Get an account entry point ruleset](https://e8aee267.previews.developers.cloudflare.com/api/resources/rulesets/subresources/phases/methods/get/) operation to obtain the definition of the entry point ruleset for the `http_request_firewall_managed` phase. You will need the [account ID](https://e8aee267.previews.developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/) for this task.  
Required API token permissions  
At least one of the following [token permissions](https://e8aee267.previews.developers.cloudflare.com/fundamentals/api/reference/permissions/) is required:
  * `Account WAF Write`
  * `Account WAF Read`
  * `Account Rulesets Read`
  * `Account Rulesets Write`  
```bash  
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rulesets/phases/http_request_firewall_managed/entrypoint" \
	--request GET \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  
```  
```json  
{  
	"result": {  
		"description": "Account-level phase entry point",  
		"id": "<RULESET_ID>",  
		"kind": "root",  
		"last_updated": "2024-03-16T15:40:08.202335Z",  
		"name": "root",  
		"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 an account ruleset rule](https://e8aee267.previews.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](https://developers.cloudflare.com/waf/managed-rules/reference/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.  
Required API token permissions  
At least one of the following [token permissions](https://e8aee267.previews.developers.cloudflare.com/fundamentals/api/reference/permissions/) is required:
  * `Account WAF Write`
  * `Account Rulesets Write`  
```bash  
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rulesets/$RULESET_ID/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{  
		"action": "execute",  
		"action_parameters": {  
				"id": "efb7b8c949ac4650a09736fc376e9aee"  
		},  
		"expression": "(cf.zone.name in {\"example.com\" \"anotherexample.com\"}) and cf.zone.plan eq \"ENT\"",  
		"description": "Execute the Cloudflare Managed Ruleset"  
	}'  
```  
```json  
{  
	"result": {  
		"id": "<RULESET_ID>",  
		"name": "Account-level phase entry point",  
		"description": "",  
		"kind": "root",  
		"version": "11",  
		"rules": [  
			// ... any existing rules  
			{  
				"id": "<RULE_ID>",  
				"version": "1",  
				"action": "execute",  
				"action_parameters": {  
					"id": "efb7b8c949ac4650a09736fc376e9aee",  
					"version": "latest"  
				},  
				"expression": "(cf.zone.name in {\"example.com\" \"anotherexample.com\"}) and cf.zone.plan eq \"ENT\"",  
				"description": "Execute the Cloudflare Managed Ruleset",  
				"last_updated": "2024-03-18T18:30:08.122758Z",  
				"ref": "<RULE_REF>",  
				"enabled": true  
			}  
		],  
		"last_updated": "2024-03-18T18:30:08.122758Z",  
		"phase": "http_request_firewall_managed"  
	},  
	"success": true,  
	"errors": [],  
	"messages": []  
}  
```  
Caution  
Managed rulesets deployed at the account level will only apply to incoming traffic of zones on an Enterprise plan. The expression of your `execute` rule must end with `and cf.zone.plan eq "ENT"` or else the API operation will fail.
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 an account ruleset](https://e8aee267.previews.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 where the zone name matches one of `example.com` or `anotherexample.com`.  
Required API token permissions  
At least one of the following [token permissions](https://e8aee267.previews.developers.cloudflare.com/fundamentals/api/reference/permissions/) is required:
  * `Account WAF Write`
  * `Account Rulesets Write`  
```bash  
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rulesets" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{  
		"name": "My ruleset",  
		"description": "Entry point ruleset for WAF managed rulesets",  
		"kind": "root",  
		"phase": "http_request_firewall_managed",  
		"rules": [  
				{  
						"action": "execute",  
						"action_parameters": {  
								"id": "efb7b8c949ac4650a09736fc376e9aee"  
						},  
						"expression": "(cf.zone.name in {\"example.com\" \"anotherexample.com\"}) and cf.zone.plan eq \"ENT\"",  
						"description": "Execute the Cloudflare Managed Ruleset"  
				}  
		]  
	}'  
```

## Next steps

To customize the behavior of the rules included in a managed ruleset, [create an override](https://e8aee267.previews.developers.cloudflare.com/ruleset-engine/managed-rulesets/override-managed-ruleset/).

To skip the execution of WAF managed rulesets or some of their rules, [create an exception](https://e8aee267.previews.developers.cloudflare.com/waf/managed-rules/waf-exceptions/define-api/) (also called a skip rule).

Exceptions have priority over overrides.

## More resources

For instructions on deploying a managed ruleset at the zone level via API, refer to [Deploy a WAF managed ruleset via API (zone)](https://e8aee267.previews.developers.cloudflare.com/waf/managed-rules/deploy-api/).

For more information on working with managed rulesets via API, refer to [Work with managed rulesets](https://e8aee267.previews.developers.cloudflare.com/ruleset-engine/managed-rulesets/) in the Ruleset Engine documentation.

Was this helpful?

YesNo

## On this page

[![](https://e8aee267.previews.developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://e8aee267.previews.developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/waf/account/managed-rulesets/deploy-api/#page","headline":"Deploy a WAF managed ruleset via API for an account · Cloudflare Web Application Firewall (WAF) docs","description":"Deploy WAF managed rulesets at the account level using the API.","url":"https://developers.cloudflare.com/waf/account/managed-rulesets/deploy-api/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","dateModified":"2026-08-24","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
