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
NopoxOP11mo ago
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Cyb3r-Jak3
Cyb3r-Jak311mo ago
Can you share an example peice of code you are using to make the API call?
Nopox
NopoxOP11mo ago
Sure this is just listing the dns records which I also get Authentication error on
No description
Nopox
NopoxOP11mo ago
Does that help or would u like the specific endpoint for dns deleting
Metriusz
Metriusz11mo ago
Just to be clear, when making a request you replace API_KEY with your actual API key?
Nopox
NopoxOP11mo 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
Metriusz11mo 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
NopoxOP11mo ago
I get the same error
Metriusz
Metriusz11mo ago
Can you send a screenshot of the permissions you have set up for the API key?
Nopox
NopoxOP11mo ago
No description
AlphaCentauri
AlphaCentauri11mo 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
Metriusz11mo 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
NopoxOP11mo ago
Im gonna give it a try with my cloudflare global api key
Cyb3r-Jak3
Cyb3r-Jak311mo 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
NopoxOP11mo ago
I mean, if the api key can create dns records it should also work for this right?
Nopox
NopoxOP11mo ago
Same thing
No description
Nopox
NopoxOP11mo ago
Is there some way to verify this api key is valid?
AlphaCentauri
AlphaCentauri11mo 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
NopoxOP11mo ago
It's disabled
Cyb3r-Jak3
Cyb3r-Jak311mo 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
NopoxOP11mo ago
I tried with just that and same error
Cyb3r-Jak3
Cyb3r-Jak311mo ago
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Cyb3r-Jak3
Cyb3r-Jak311mo 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
NopoxOP11mo ago
Token valid
No description
Nopox
NopoxOP11mo ago
I'm really not sure what else I can do to test
Cyb3r-Jak3
Cyb3r-Jak311mo ago
Can you double check the zone id is correct?
Nopox
NopoxOP11mo ago
Exposing the zone id can't do any harm right
Cyb3r-Jak3
Cyb3r-Jak311mo ago
No. Zone and Account are fine to make public
Nopox
NopoxOP11mo ago
No description
No description
Cyb3r-Jak3
Cyb3r-Jak311mo 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
NopoxOP11mo ago
No description
Nopox
NopoxOP11mo 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-Jak311mo ago
Can you try adding the read permission to the api token?
Nopox
NopoxOP11mo ago
Looks like it is working now, must have been this because I didn't modify anything else. Appreciate the help!
Want results from more Discord servers?
Add your server