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: https://api.cloudflare.com/
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.
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.
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.
What if I am using the host API at https://api.cloudflare.com/host-gw.html with a partners.Cloudflare.com account?
I tried to pass the -d ‘jump_start=false’ to https://api.cloudflare.com/host-gw.html 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.
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 => https://api.cloudflare.com/#zone-create-zone
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 “https://api.cloudflare.com/client/v4/zones/".$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?