DELETE all records using API


Currently I am trying to automate the move of many domains from an existing DNS service provider to Cloudflare. I am using the API to do this:

The problem I encounter is that when I add a new zone via the API then it automatically queries its current DNS settings and adds them into Cloudflare.

Is it possible to change this behavior so when a new zone is added it gets added with no records at all? Or is there an API call that I can use to DELETE all current records rather than one by one?

Please let me know.
Thanks in advance.

1 Like

Hey there,

There isn’t a bulk delete call, I’m afraid. However, you should be able to script this.
List the DNS records, filter for the ID and pass that into the delete call.
Hope this helps.

1 Like


Too bad. Then I guess I will have to do the lookup first.


If you add the zone via API I believe you can tell us not to scan existing records:

Set jump_start to false. Obviously at that point you’re on the hook for creating whatever DNS records need to be created in your zone (via API, BIND file import or manual creation).




Thanks!. That is exactly what I was looking for.

Me again,

What if I am using the host API at with a account?

I tried to pass the -d ‘jump_start=false’ to but that did not do anything

Please let me know

Hmm… I don’t see it listed in our internal docs either. We are working on improving parity/ consolidating some APIs to make things easier for partners and this may be on the list.

Course I could also be just flat out wrong, I’d recommend pinging support to see if they have a better answer. They’re way smarter than I am when it comes to the partner APIs. :wink:

1 Like

Creating the zone via the API is very quick and works perfectly!

To make it even quicker, I suggest using Postman and importing the Postman collection from Cloudflare:

Then, you only need to create a Postman environment for the variables x-auth-email (your account’s email) and x-auth-key (the Global key you can find in your Cloudflare profile).


PS: the documentation link has changed => Cloudflare API v4 Documentation

Hi Mr.@cs-cf, how can I add some specific DNS records under my domain using API call? currently i use create zone API by setting jump_start = false. then calling Scan API ““.$zoneid.”/dns_records/scan” ---- which create 7 records But I want to have only 4 records. How can I do that in one API call?

you can check my question with more details here: How to create some certain dns records using API

any guidance or suggestion would be appreciated.


You can’t. You can either use a BIND file as @sdayman suggested in the other thread or make a call for each record you want to create. You can dynamically create the BIND file, or you can call and create the individual records.


Why is this made so difficult for users? Why not a button on the dashboard… okay, I can understand, but still, would be awesome! But why not even through the API? I think users who use the API know what they’re doing, right?

Hey, I built a tool to bulk-delete DNS records. Check it out: (the source code is here: GitHub - th0th/cloudflare-dns: A simple tool for bulk-deleting DNS records on CloudFlare.)

Finally got it working all using command line without writing any script. In my case there were about 1000 DNS records. so I had to get all of them page by page

Part 1 = Finding API Tokens and zone id

Step 1: Create an API token =
Step 2: Find Zone id = Find zone and account IDs · Cloudflare Fundamentals docs

Part 2: Execution
check next post = as cloudflare not allowing me to put more than 2 links…

followup on previus post

Part 2: Execution

Step 3: Fetch all records (Make sure you give access to that zone while creating token). In the below query, per_page and page are optional if you have more than 100 records.

curl --request GET
–url ‘<page_zone_id_here>/dns_records?per_page=100&page=1’
–header ‘Content-Type: application/json’
-H “Authorization: Bearer <paste_token_here>”

Result should look something like this


“id”:“ebe5df1f1de14b78a21bd8c83eeb70c8” = this record id which you would want to delete

Step 4: Delete all records. You can use sublime text editor or of your choice to bulk edit the text.

Delete Command

curl --request DELETE
–header ‘Content-Type: application/json’
-H “Authorization: Bearer <token_here>”

So bullk delete command will look something like this, copy paste this in command line and it will delete in one shot. To increase the speed, add “&” in the end of command so that command will run in background.