How can I remove the 150+ A record subdomains that got created automatically?

I have over 150 extra A-records/subdomains (e.g. 4g,a, ads, pay, …) ), which got added automatically.
What’s the easiest way to remove all of them?

Delete via Cloudflare API programmatically should be the best way to remove all of them. Consider reading this article (I never tried this though):

1 Like

I’d be interested also on how to prevent this from happening;
I tried removing and re-creating the CF website, but it’s always adding the 150+ silly A-records…

You may also use the Cloudflare API to add zones to your account, with an additional parameter to tell Cloudflare not to scan for existing DNS records and automatically add them all together.

I have a Bash script that looks like this:


# this script allows you do add multiple domains/zones in batch, eliminate the need to add one by one via Cloudflare Dashboard.
# before you run this script, ensures that you create an API token which has the following permission:
# Zone - Zone - Edit
# Includes - All zones from an account - "The account that you want to add the new zone in"

# please put all the domains inside the file called domains.txt
# remember to make this script file executable (chmod +x
# remember to update the API Token and Account ID below


for domain in $(cat domains.txt); do \
  curl -X POST -H "Authorization: Bearer $_CFAPITOKEN" \
  -H "Content-Type: application/json" \
  "" \
  --data '{"account": {"id": "'$_CFAPIACCOUNTID'"}, "name":"'$domain'","jump_start":false}'; done

Unfortunately there’s no switch in Cloudflare Dashboard to tell Cloudflare not to scan for existing DNS records, this is only doable via the API.

1 Like

@stef.andries what zone are you seeing this on and when was it first added to Cloudflare?

Our DNS team made some changes many months ago to fix this problem but if your domain was first added before that, these may be records that were scanned in before that change.

I added it for the first time over a year ago.
When I removed it and re-added it, the same subdomains just come back :-/

Got it - so these records were scanned in for you back when you first added it over a year ago, before this issue was fixed.

As your domain has remained on Cloudflare during that time, the old records only get purged if you move your nameservers away for an extended period of time.

To resolve this, you will need to remove the records manually via the UI or in bulk via API scripting.

I’m not a pro at using the API unfortunately :frowning:
Isn’t there a way to export / edit (delete) / import the DNS records?


That’s available:


Yep, but you cannot *remove entries using this method :-/

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.