This guide helps you find the Cloudflare IDs needed for configuration.
- Cloudflare account with API token
curlor similar HTTP clientjqfor JSON parsing (optional but recommended)
Both are visible in the Cloudflare dashboard by going to:
- Dashboard → Select your domain → Overview (right sidebar, under "API")
Create a token with these permissions:
- Account: Account Rulesets:Edit, Account Filter Lists:Edit, Account Firewall Access Rules:Edit
- Zone: Zone:Read, Firewall Services:Edit
Dashboard → My Profile → API Tokens → Create Token
First, create an IP List in Cloudflare dashboard:
- Dashboard → Manage Account → Configurations → Lists → Create new list
Then get the List ID via API:
curl -X GET "https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/rules/lists" \
-H "Authorization: Bearer {API_TOKEN}" \
-H "Content-Type: application/json" | jq '.result[] | {id, name}'Find your list by name and copy the id.
First, create a WAF rule in Cloudflare dashboard:
- Dashboard → Select domain → Security → WAF → Create rule
- Set expression to:
(ip.src in {}) - Set action (e.g., "Block")
- Deploy the rule
Then get the Ruleset ID:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/rulesets" \
-H "Authorization: Bearer {API_TOKEN}" \
-H "Content-Type: application/json" | jq '.result[] | select(.phase=="http_request_firewall_custom") | {id, name}'Copy the ruleset id.
Then get the Rule ID:
curl -X GET "https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/rulesets/{RULESET_ID}" \
-H "Authorization: Bearer {API_TOKEN}" \
-H "Content-Type: application/json" | jq '.result.rules[] | {id, description}'Find your rule by description and copy the id.
Copy .env-EDITME to .env and fill in all the values:
cp .env-EDITME .env
nano .env # or your preferred editorAlways test with dry-run first:
# Test blocklist sync
cd update-blocklist
python cf_blocklist_update.py --dry-run
# Test WAF rule sync
cd update-waf-rules
python cf_ruleset_update.py --dry-run"Rule with ID not found"
- Verify the RULESET_ID and RULE_ID are correct
- Ensure the rule exists in the specified zone