Add IPs to all sites

Hi,

Hoping that you are well, I would like if you can instruct me on how to go adding by API, IPs in the IP Access Rules module but for all sites as in the documentation only indicates that you must enter zone id of each site but is there any API parameter or script example that does it for all sites, this is more than anything to globalize a blocklist of malicious IP addresses and not be adding one by one on each site.

Currently I only see this API “https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/access_rules/rules”.

Greetings.

You have to first call the zones endpoint to get a list of the zone IDs…
https://developers.cloudflare.com/api/operations/zones-get
…then loop round each in turn calling the IP Access Rules endpoint for each zone.

Not needed, Cloudflare has a native function to apply an IP access rule to all sites:

image

This uses the account-level IP Access Rule endpoint, rather than the zone one: https://developers.cloudflare.com/api/operations/ip-access-rules-for-an-account-create-an-ip-access-rule

So @telecommillenium810 you just need to use the account-level endpoint: https://api.cloudflare.com/client/v4/accounts/{account_identifier}/firewall/access_rules/rules

1 Like

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