Last active
October 3, 2024 15:42
-
-
Save meetox80/cc66bc537ba67504380b73ef01f9ddc1 to your computer and use it in GitHub Desktop.
Cloudflare bulk delete all DNS records
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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