How do I enable my customer WAF rule from API?

Hello, I have been searching how to enable WAF customer rules via API rule but can’t get exact answer or having lot of issue implementing from forum answer. I have no idea which one I have to use rule ID and which one I have to put in API since I am not really developer myself. Just simpley want to enable my rule from script. When I make change from GUI i saw below in my audit log. Can someone help how do I write curl script to enable it?

Resource:rulesets
Resource ID: 291236c4e23233cf985b34e67d267f3
New Value:
{
  "modified_rules": [
    {
      "action": "managed_challenge",
      "description": "All Challenge",
      "enabled": false,
      "expression": "(xxxxxxxx)",
      "id": "482d2d2384e2255b8c040f9722f0d979",
      "last_updated": "2024-05-02T12:33:40.483432Z",
      "ref": "482d2d2384e2255b8c040f9722f0d979",
      "version": "7"
    }
  ],
  "rule_ids": [
    "ad34268b80164432352a2f327aecaa24",
    "ccdbd82498b04eb22222a9b6f850d4dc",
    "482d2d2384e2255b8c040f9722f0d979"
  ],
  "version": "10"
}


OLD VALUE:
{
  "modified_rules": [
    {
      "action": "managed_challenge",
      "description": "All Challenge",
      "enabled": true,
      "expression": "(xxxxxxxx)",
      "id": "482d2d2384e2255b8c040f9722f0d979",
      "last_updated": "2024-05-02T12:33:35.815911Z",
      "ref": "482d2d2384e2255b8c040f9722f0d979",
      "version": "6"
    }
  ],
  "rule_ids": [
    "ad34268b80164432352a2f327aecaa24",
    "ccdbd82498b04eb22222a9b6f850d4dc",
    "482d2d2384e2255b8c040f9722f0d979"
  ],
  "version": "9"
}

Script i have tired and not work 
curl https://api.cloudflare.com/client/v4/zones/$zonid
/rulesets/$ruleid????/rules \
-H "X-Auth-Email: [email protected]" \
-H "X-Auth-Key: Xxxxxxxxxxxxxxxxxxxxxxxxxxxxx7" \
-H "Content-Type: application/json" \    
--data "{\"enabled\":true}"

Hi there,

Please check this API examples to update WAF rules:

  1. List/Get the Rules
  2. Update the rules

Thank you.

1 Like

The guide is Deprecated? Is there new method on this?

You are correct, those API calls are for the old Managed Rules

For creating a Custom Rule you would want to use

For the current Managed Rules you can create an override

or an exception

Add an exception via API · Cloudflare Web Application Firewall (WAF) docs.