Deploy rulesets

Last updated Apr 16, 2026 Use the Rulesets API to deploy a ruleset. To deploy a ruleset, add a rule with "action": "execute" to a phase entry point ruleset, specifying the ruleset ID to execute as an action parameter. Use a separate rule for each ruleset you want to deploy.

A rule that executes a ruleset consists of:

  • The ID of the ruleset you want to execute, included in action_parameters.id.
  • An expression.
  • The execute action.

The rules in the ruleset execute when a request satisfies the expression.

Note

To apply a rule to every request in a phase at the zone level, set the rule expression to true.

Example

The following example deploys the Cloudflare Managed Ruleset (with ID ...376e9aee) to the http_request_firewall_managed phase of a given zone ($ZONE_ID) by adding a rule that executes the managed ruleset.

<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>Response Compression Write</code>
  • <code>Config Settings Write</code>
  • <code>Dynamic URL Redirects Write</code>
  • <code>Cache Settings Write</code>
  • <code>Custom Errors Write</code>
  • <code>Origin Write</code>
  • <code>Managed headers Write</code>
  • <code>Zone Transform Rules Write</code>
  • <code>Mass URL Redirects Write</code>
  • <code>Magic Firewall Write</code>
  • <code>L4 DDoS Managed Ruleset Write</code>
  • <code>HTTP DDoS Managed Ruleset Write</code>
  • <code>Sanitize Write</code>
  • <code>Transform Rules Write</code>
  • <code>Select Configuration Write</code>
  • <code>Bot Management Write</code>
  • <code>Zone WAF Write</code>
  • <code>Account WAF Write</code>
  • <code>Account Rulesets Write</code>
  • <code>Logs Write</code>
  • <code>Logs Write</code>

</details>

Update a zone entry point rulesetbash

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",
                        "action_parameters": {
                                "id": "efb7b8c949ac4650a09736fc376e9aee"
                        },
                        "expression": "true",
                        "description": "Execute Cloudflare Managed Ruleset on my zone ruleset"
                }
        ]
    }'
{
    "result": {
        "id": "<ZONE_PHASE_RULESET_ID>",
        "name": "Zone-level Ruleset 1",
        "description": "",
        "kind": "zone",
        "version": "latest",
        "rules": [
            {
                "id": "<RULE_ID>",
                "version": "1",
                "action": "execute",
                "action_parameters": {
                    "id": "efb7b8c949ac4650a09736fc376e9aee",
                    "version": "3"
                },
                "expression": "true",
                "description": "Execute Cloudflare Managed Ruleset on my zone ruleset",
                "last_updated": "2021-03-18T18:08:14.003361Z",
                "ref": "<RULE_REF>",
                "enabled": true
            }
        ],
        "last_updated": "2021-03-18T18:08:14.003361Z",
        "phase": "http_request_firewall_managed"
    },
    "success": true,
    "errors": [],
    "messages": []
}

Caution

This API request replaces any existing rules in the http_request_firewall_managed phase entry point ruleset with a single rule.

For more examples of deploying rulesets, refer to the following pages:

Refer to Work with managed rulesets and Work with custom rulesets for more information.

For more information on the available API endpoints for editing and deploying rulesets, refer to Update or deploy a ruleset.

Was this helpful?

YesNo

On this page

Deploy rulesets - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ruleset-engine/basic-operations/deploy-rulesets/#page","headline":"Deploy rulesets","description":"Deploy rulesets to a phase entry point using the API.","url":"https://developers.cloudflare.com/ruleset-engine/basic-operations/deploy-rulesets/","inLanguage":"en","image":"https://developers.cloudflare.com/ruleset-engine/basic-operations/deploy-rulesets/og.png?v=d693e7b814318c5d","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: View existing rulesets and their rules using the API. title: View rulesets image: https://developers.cloudflare.com/ruleset-engine/basic-operations/view-rulesets/og.png?v=8ac41a5e04ad5fd1


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/ruleset-engine/llms.txt
Use this file to discover all available pages before exploring further.