Skip to content

Instantly share code, notes, and snippets.

@suciptoid
Created September 10, 2021 08:29
Show Gist options
  • Save suciptoid/4a4b7d3f2e8e516452cb8a556d8bf881 to your computer and use it in GitHub Desktop.
Save suciptoid/4a4b7d3f2e8e516452cb8a556d8bf881 to your computer and use it in GitHub Desktop.
Bulk Delete Cloudflare domain Records
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