Help with the CloudFlare DNS Overwrite API

What is the name of the domain?

the-emberhood.net

What is the error number?

none

What is the error message?

none

What is the issue you’re encountering

I’m new to Cloudflare so I’m not sure if I am posting this in the correct place here. If not, please forgive me. Can you please tell me where I can find the information highlighted in BOLD ITALICIZED in the API: curl https://api.cloudflare.com/client/v4/zones/__**$ZONE_ID**__/dns_records/__**$DNS_RECORD_ID**__ \ -X PUT \ -H ‘Content-Type: application/json’ \ -H "X-Auth-Email: $CLOUDFLARE_EMAIL" \ -H "X-Auth-Key: $CLOUDFLARE_API_KEY" \ -d ‘{ “comment”: “Domain verification record”, “content”: “198.51.100.4”, “name”: “example.com”, “proxied”: true, “settings”: { “ipv4_only”: true, “ipv6_only”: true }, “tags”: [ *“owner:dns-team”** ], “ttl”: 3600, “type”: “A” }’

What steps have you taken to resolve the issue?

Please help! I have searched for a couple of months to find it. I’m 99% certain I have found the “Zone ID”, the “Cloudflare Email”, and the “Cloudflare API Key”. What I have not been able to find is the “DNS Record ID”, the “Owner Verification Record”, and the “Owner:dns-team”.

What are the steps to reproduce the issue?

none

Screenshot of the error

I was just checking to see if anyone had replied to my post, and I noticed I said one of the things I could not find was “the “Owner Verification Record””. What I meant to say was the “Domain Verification Record”. Sorry for any confusion this may have caused.

Can you explain what exactly you are trying to achieve? Do you want to update a DNS record with a new IP address or something like that?

I’m to self host a website for my family but I’m behind a dynamic IP Address. So yes, I’m trying to change my IP Address in the DNS servers using CloudFlares DDNS service.

In that case, you would want to first run a List DNS Records call - this will give you the record ID.

Next, you want to run an Update DNS Record call to change the actual IP address.

You should use Update instead of Overwrite so that the record ID doesn’t change every time.

That’s the email address of your Cloudflare account

You can see your API Key in your account settings.

A comment is something you can make up yourself or just leave empty.

Tags are also something you can make up yourself, it’s purely to help you with organization if you have a lot of records.

So in “My Profile” I found “API Tokens”. In there I found three things:
1.) “API Tokens”
2.) “Global API Key”
3.) “Origin CA Key”
Which one do I use for “X-Auth-Key: $CLOUDFLARE_API_KEY”?

Also, are you saying I can just delete “comment”: “Domain verification record” and “tags”: [ “owner:dns-team”* ] from the script from the "Update DNS Record script?

That one.

Yes.

The only field you need to update a DNS record is the content field, in which you pet the new IP address. You don’t need name, proxied, settings, tags, ttl or any other.

I thought Cloudflare had an automatic DDNS feature from all the videos I have seen.

No, Cloudflare doesn’t have that.

There are other tools that can update your IP on Cloudflare though.

Some people also use other DDNS services and just set a Cname on Cloudflare to the DDNS hostname.

There are also Cloudflare Tunnels, which would be the preferred solution unless your website is a private filesharing website.

The tunnel is a software that you install on your server that connects to Cloudflare, instead of Cloudflare trying to connect to your server via A records.

Oh! Okay. Thank you for letting me know that. After I get this all straightened out, I guess the next step would be to look into the tunnel. What is the “$DNS_RECORD_ID”?

You get the record ID from the List DNS Records call. It’s the id field.

curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records \
    -H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
    -H "X-Auth-Key: $CLOUDFLARE_API_KEY"

Thank you. The List DNS Script worked great. However, I got the following error message when I ran the Update DNS script:

{“result”:null,“success”:false,“errors”:[{“code”:9300,“message”:“DNS record has 1 tags, exceeding the quota of 0.”},{“code”:9227,“message”:“The IPv4 Only and IPv6 Only settings are not available to this zone.”}],“messages”:}

That sounds like you didn’t remove all the other options.

Okay. I will try that.

So I got the UPDATE DNS script to work, but it only updates one of the “A” records.

It updated the “A” record named:
the-emberhood.net

It did not update the following “A” records:
*
www

I tried adding:
“name”: “www”,
**“name”: “*”, **

It still didn’t work, so I tried adding:
“content”: “74.152.38.21”,
above the previous additions so it looked like this:
“content”: “74.152.38.21”,
“name”: “www”,
“content”: “74.152.38.21”,
**“name”: “*”, **

It still didn’t work. How do I get it to update those?

Run the script again with the ID of those records. Every record has it’s own ID.

Very strange. I changed “name”: “the-emberhood.net”, to “name”: “*”,. It did change the “A” record name “" but it also kept the IP Address for the same name. Basically, it created a new “A” record named "”. AND it reset the IP address for “A” record named the-emberhood.net back to the previous IP Address.

I deleted the A"A record name “" that still had the previous IP Address and in the script, I changed **“name”: "”,** to “name”: “www”,. It updated that record with the new IP Address but also kept the the original IP Address for the “A” record named 'www". However, it removed the “A” record named “*”.

I will get the DNS records set back up the way they originally and upload screenshots for you if needed. Just let me know if you need me to do that.

Why do you even have name in your script? You only need content.

What would I need screenshots of your DNS records for?

I went back to the way the records were set up in the beginning:
Type Name Content
A script 8.8.8.8
A * 24.60.51.219
A the-emberhood 24.60.51.219
A www 24.60.51.219

After running the Update DNS script:
-d ‘{
“content”: “74.152.38.21”,
“proxied”: true,
“ttl”: 3600,
“type”: “A”
}’

I ended up with:
Type Name Content
A script 274.62.95.211
A * 24.60.51.219
A the-emberhood 24.60.51.219
A www 24.60.51.219

I know I’m screwing up somewhere. I’m new at all of this and I thank you for you patience.

From the beginning:

You want to start by listing your DNS records and noting the IDs of the records that you want to update:

curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records \
    -H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
    -H "X-Auth-Key: $CLOUDFLARE_API_KEY"

Then, you can perform an Update call for each ID:

curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID \
    -X PATCH \
    -H 'Content-Type: application/json' \
    -H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
    -H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
    -d '{
      "content": "198.51.100.4"
    }'

So if you want to update 3 records, you do this 3 times.