Deleting DNS Record with API Endpoint

I am attempting to delete a dns record from our zone and I am only getting the status code 10000 and "Authentication error", I am using the same api key to create dns records which works fine but no matter which headers I put in, Ex. X-Auth-Key, X-Auth-Email, Authorization I just get the same error (putting these in all at the same time). The email I provided is the owner of this domain on cloudflare and the api key is the one I use to create dns records.
35 Replies
Nopox
Nopox6mo ago
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Can you share an example peice of code you are using to make the API call?
Nopox
Nopox6mo ago
Sure this is just listing the dns records which I also get Authentication error on
No description
Nopox
Nopox6mo ago
Does that help or would u like the specific endpoint for dns deleting
Metriusz
Metriusz6mo ago
Just to be clear, when making a request you replace API_KEY with your actual API key?
Nopox
Nopox6mo ago
Yeah, same for email and Authorization I'm not sure what email is supposed to be there but I replaced it with the email that created this specific api key
Metriusz
Metriusz6mo ago
I think you can skip both of those when using the Authorization header with an API key In fact you may want to try that
Nopox
Nopox6mo ago
I get the same error
Metriusz
Metriusz6mo ago
Can you send a screenshot of the permissions you have set up for the API key?
Nopox
Nopox6mo ago
No description
AlphaCentauri
AlphaCentauri6mo ago
Instead of trying to set the headers manually, why don't you clear everything from there and within Insomnia just select Auth > Bearer Token and then just paste in your token without the Bearer prefix? Might solve the issue
Metriusz
Metriusz6mo ago
That seems right, you could try double checking if the zone ID is right, as well as temporarily increasing the permissions for the API key to the issue might be related to that
Nopox
Nopox6mo ago
Im gonna give it a try with my cloudflare global api key
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Yeah if you are using an api token then you only need the authorization header. You should never have all 3 auth headers
Nopox
Nopox6mo ago
I mean, if the api key can create dns records it should also work for this right?
Nopox
Nopox6mo ago
Same thing
No description
Nopox
Nopox6mo ago
Is there some way to verify this api key is valid?
AlphaCentauri
AlphaCentauri6mo ago
Did you do what I mentioned? I just checked my Insomnia installation, and your second tab says 'Bearer', so I'm guessing you have specified a key there too so you're sending that header twice?
Nopox
Nopox6mo ago
It's disabled
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Do you mean the global key? If so then yes, but you need the x-auth-email header. You need both x-auth-email and x-auth-key header if using global auth or just the authorization header if using an api token
Nopox
Nopox6mo ago
I tried with just that and same error
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Only other thing would be double checking the zone id. Just a sanity check that you followed https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/#find-zone-and-account-ids to get the zone id
Nopox
Nopox6mo ago
Token valid
No description
Nopox
Nopox6mo ago
I'm really not sure what else I can do to test
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Can you double check the zone id is correct?
Nopox
Nopox6mo ago
Exposing the zone id can't do any harm right
Cyb3r-Jak3
Cyb3r-Jak36mo ago
No. Zone and Account are fine to make public
Nopox
Nopox6mo ago
No description
No description
Cyb3r-Jak3
Cyb3r-Jak36mo ago
What if you do a bare bones request with curl like
curl --request GET \
--url https://api.cloudflare.com/client/v4/zones/<zone id>/dns_records \
--header 'Authorization: Bearer <token>
curl --request GET \
--url https://api.cloudflare.com/client/v4/zones/<zone id>/dns_records \
--header 'Authorization: Bearer <token>
Nopox
Nopox6mo ago
No description
Nopox
Nopox6mo ago
I tried making a support ticket for this but I don't have a paid plan I just tried converting my code for adding dns records to a curl command and received an authentication error but I just double checked and my add dns record works still
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Can you try adding the read permission to the api token?
Nopox
Nopox6mo ago
Looks like it is working now, must have been this because I didn't modify anything else. Appreciate the help!