Skip to content

Instantly share code, notes, and snippets.

@meetox80
Last active October 3, 2024 15:42
Show Gist options
  • Save meetox80/cc66bc537ba67504380b73ef01f9ddc1 to your computer and use it in GitHub Desktop.
Save meetox80/cc66bc537ba67504380b73ef01f9ddc1 to your computer and use it in GitHub Desktop.
Cloudflare bulk delete all DNS records
@echo off
setlocal enabledelayedexpansion
set "zoneid=zone_id"
set "bearer=bearer"
curl --silent --request GET "https://api.cloudflare.com/client/v4/zones/%zoneid%/dns_records?per_page=50000" --header "Authorization: Bearer %bearer%" --header "Content-Type: application/json" > dns_records.json
if not exist dns_records.json (
echo Failed to fetch DNS records.
endlocal
exit /b 1
)
for /f "delims=" %%i in ('jq.exe --raw-output ".result[].id" dns_records.json') do (
echo Deleting DNS Record ID: %%i
curl --silent --request DELETE "https://api.cloudflare.com/client/v4/zones/%zoneid%/dns_records/%%i" --header "Authorization: Bearer %bearer%" --header "Content-Type: application/json"
)
del dns_records.json
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment