Created
September 10, 2021 08:29
-
-
Save suciptoid/4a4b7d3f2e8e516452cb8a556d8bf881 to your computer and use it in GitHub Desktop.
Bulk Delete Cloudflare domain 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
const res = await fetch("https://dash.cloudflare.com/api/v4/zones/<your zone id>/dns_records?per_page=150", { | |
"headers": { | |
"x-atok": "<get from inspect network request>", | |
"x-cross-site-security": "dash" | |
}, | |
"method": "GET", | |
}); | |
const data = await res.json() | |
const records = data['result'] | |
records.filter(f => f.content != "76.76.21.21").forEach(async f => { | |
const del = await fetch("https://dash.cloudflare.com/api/v4/zones/<your zone id>/dns_records/"+f.id, { | |
"headers": { | |
"x-atok": "<get from inspect network request>", | |
"x-cross-site-security": "dash" | |
}, | |
"method": "DELETE", | |
}); | |
const delRes = await del.json() | |
console.log('delete '+f.id+' result', delRes) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment