Multiple rule add in cloudflare IP firewall via automation

Hi guys,
I was configure a script for added multiple ASN rule on IP firewall, it is successfully created rule, but few of the option is unable to do it.
Below is the script i do:

ASN_name=$(cat ASN_name.txt)

for ASN_name in ASN_name; do update=(curl -X POST “https://api.cloudflare.com/client/v4/zones/xxxxxxxxxxx/firewall/access_rules/rules” -H “X-Auth-Email: $auth_email” -H “X-Auth-Key: $auth_key” -H
“Content-Type: application/json” --data “{ “mode”:“whitelist,“configuration”:{“target”:“asn”,“value”:”$ASN_name”},“notes”:“CHINANET-BACKBONE”}")

if [[ $update != ““success”:true” ]]; then
message="$ASN_name FAILED create domain. DUMPING RESULTS: $update"
log “$message”
echo -e “$message”
#exit 1
else
message="$ASN_name domain created"
log “$message”
echo “$message”

fi
done

I need to configure the “mode : All websites in account.” Example : (Cloudflare.png), i was check the Cloudflare Api document but can’t find it.

https://api.cloudflare.com/#firewall-access-rule-for-a-zone-create-access-rule

Note: If you would like to create an access rule that applies across all of your owned zones, use the user or organization firewall endpoints as appropriate.

So I’d assume https://api.cloudflare.com/#account-level-firewall-access-rule-create-access-rule

This topic was automatically closed after 14 days. New replies are no longer allowed.