Update IP Access Rule via API


I’m trying to update my IP Access Rule IP address via API with:

curl -X PATCH "https://api.cloudflare.com/client/v4/accounts/MYDATA/firewall/access_rules/rules/MYDATA" \
     -H "X-Auth-Email: MYMAIL" \
     -H "X-Auth-Key: MYKEY" \
     -H "Content-Type: application/json" \
     --data '{"id":"MYID","notes":"MYNAME","allowed_modes":["whitelist","block","challenge","js_challenge","managed_challenge"],"mode":"whitelist","configuration":{"target":"ip","value":"MYIP"},"scope":{"id":"MYSCOPEiD","email":"MYMAIL","type":"user"}}'

I can change the note, the mode but not the IP.

I get no error from the API, it simply doesn’t change the IP address. The documentation gives this exact example:

curl -X PATCH "https://api.cloudflare.com/client/v4/accounts/01a7362d577a6c3019a474fd6f485823/firewall/access_rules/rules/92f17202ed8bd63d69a66b86a49a8f6b" \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
     -H "Content-Type: application/json" \
     --data '{"id":"92f17202ed8bd63d69a66b86a49a8f6b","notes":"This rule is enabled because of an event that occurred on date X.","allowed_modes":["whitelist","block","challenge","js_challenge","managed_challenge"],"mode":"challenge","configuration":{"target":"ip","value":""},"created_on":"2014-01-01T05:20:00.12345Z","modified_on":"2014-01-01T05:20:00.12345Z","scope":{"id":"7c5dae5552338874e5053f2534d2767a","email":"[email protected]","type":"user"}}'

Any hint?

Thank you!

I recommend you to first LIST your rules:

then try to update the specific IP, using that information.

If you continue to struggling, just create a new rule and delete the old one.

I get your point, but as per the official documentation my Curl request should update the IP address and it doesn’t happen.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.