Cloudflare Bulk Delete DNS Records

DOMAIN=sskaje.me
EMAIL=sskaje@mail.sskaje.me
KEY=this.is.cloudflare.key


ZONE_ID=$(curl -s -H "X-Auth-Email: ${EMAIL}" -H "X-Auth-Key: ${KEY}" "https://api.cloudflare.com/client/v4/zones" | jq -r '.result[] | select(.name == "'$DOMAIN'") | .id')


for RECORD_ID in $(curl -s -H "X-Auth-Email: ${EMAIL}" -H "X-Auth-Key: ${KEY}" "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records"| jq -r '.result[] | select(.name | test("_acme-challenge"))  | .id'); do
echo $ZONE_ID $RECORD_ID; 
curl -s -H "X-Auth-Email: ${EMAIL}" -H "X-Auth-Key: ${KEY}" -XDELETE "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}";
done

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *