Hi!
Please make it possible to bulk delete DNS records when importing a site.
I have taken over a domain with > 200 DNS records, now need to click 400 times to get rid of them all
Hi!
Please make it possible to bulk delete DNS records when importing a site.
I have taken over a domain with > 200 DNS records, now need to click 400 times to get rid of them all
I used this script to do it in C# .NET 6.0. You need to remove the spaces in the Uri part (I had to add the spaces so I could submit it here)
āā'csharp
using System.Net.Http.Headers;
using Newtonsoft.Json;
const string token = āCloudflare_tokenā;
const string zone = āCloudflare_website_zoneā;
var client = new HttpClient();
client.BaseAddress = new Uri(āhttps :// api.Cloudflare .com /client/v4/ā);
var msg = new HttpRequestMessage(HttpMethod.Get, $āzones/{zone}/dns_records?per_page=300ā);
msg.Headers.Add(āAuthorizationā, $āBearer {token}ā);
msg.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(āapplication/jsonā));
var result = await client.SendAsync(msg);
// Newtonsoft JsonCovert (System.Text.Json can not handle dynamic correctly yet)
var data = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync());
foreach (var r in data.result)
{
Console.WriteLine(āRecord {0}, name {1}, content {2}, id {3}ā, r.type, r.name, r.content, r.id);
var delRq = new HttpRequestMessage(HttpMethod.Delete, $āzones/{zone}/dns_records/{r.id}ā);
delRq.Headers.Add(āAuthorizationā, $āBearer {token}ā);
var delResult = await client.SendAsync(delRq);
if (!delResult.IsSuccessStatusCode)
Console.WriteLine($āCould not delete. Status: {delResult.StatusCode} Error: {delResult.ReasonPhrase} {await delResult.Content.ReadAsStringAsync()}ā);
}
āāā
I have been struggling with the same issue and built a simple tool to delete DNS records in bulk. Check it out: https://cloudflare-dns-th0th.vercel.app (the source code is here: GitHub - th0th/cloudflare-dns: A simple tool for bulk-deleting DNS records on CloudFlare.)
Thank you!
The code works great!
You saved me a lot of time
My gratitude will forever haunt you!
Donāt worry anymore, just do this, I deleted 800+ DNS Records in like a minute with this
[Bulk Delete Cloudflare DNS Records]https://ekg.com.np/bulk-delete-cloudflare-dns/
A post was split to a new topic: How do I manage DNS?
This is a godsend! Thank you SO MUCH for creating this and making it available for use.