Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mckabue/86e0f23bede9126d7b74f7884c04a88b to your computer and use it in GitHub Desktop.
Save mckabue/86e0f23bede9126d7b74f7884c04a88b to your computer and use it in GitHub Desktop.
Delete all DNS records for specified zone
#!/bin/bash
[email protected]
KEY=11111111111111111111111111
ZONE_ID=2222222222222222222222222
curl -X GET https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records?per_page=500 \
-H "X-Auth-Email: ${EMAIL}" \
-H "X-Auth-Key: ${KEY}" \
-H "Content-Type: application/json" | jq .result[].id | tr -d '"' | (
while read id; do
curl -X DELETE https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${id} \
-H "X-Auth-Email: ${EMAIL}" \
-H "X-Auth-Key: ${KEY}" \
-H "Content-Type: application/json"
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment