Skip to content

Instantly share code, notes, and snippets.

@aleofreddi
Created August 1, 2024 17:10
Show Gist options
  • Save aleofreddi/b5edf229bf2fb6d6b028c1c779560716 to your computer and use it in GitHub Desktop.
Save aleofreddi/b5edf229bf2fb6d6b028c1c779560716 to your computer and use it in GitHub Desktop.
Cloudflare: remove all DNS records for a zone
zoneid=<<zoneid>>
bearer=<<bearer>>
curl \
--header "Authorization: Bearer $bearer" \
-s "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records?per_page=50000" \
| jq -r '.result[].id' \
| xargs -n 1 -I {} -P 20 -- curl --silent --request DELETE \
--header "Authorization: Bearer $bearer" \
"https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records/{}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment