Can't use DELETE method with API token


For the past days I’ve been trying to make work the DELETE method through the Cloudflare API using an API token (since an API key has too much access, I have multiple domains on the account).

This is what my curl request looks like:

curl -X DELETE "$ZONE/dns_records?type=A&name=$SERVERADD" \
    -H "Authorization: Bearer $API_TOKEN" \
    -H "Content-Type: application/json"

And this is my response:

{"success":false,"errors":[{"code":10000,"message":"DELETE method not allowed for the api_token authentication scheme"}]}

Which made me think maybe the API token really is not allowed for the DELETE method (which would be weird and inefficient) but by searching it seems the same response error can be seen for simply putting the url wrong and on other request methods.

But I can’t find a solution for my delete method so I’m here to ask for help or a confirmation if it’s really not possible.

Thank you in advance.

That is not the correct endpoint for deleting DNS records. The error is confusing though.

Here’s the correct endpoint: Cloudflare API Documentation

1 Like

So it’s simply not possible? Because this endpoint requires an API key and not an API token after testing it which is really not preferable because I limited this token to only zone on purpose.

Though what’s confusing me is on the documentation page there’s also the Bearer Auth method?

The way auth is explained in the new API docs is stupid. You can use either an API key + email or an API token (the bearer auth). Just use your existing command but replace the endpoint with the one from the docs.

1 Like

I see what you meant I didn’t see they used “/dns_records/identifier”.

After finding my ID with the GET method by listing my domains I tried it with the DELETE and you’re right it works!

{"result":{"id":"(ID HERE)"},"success":true,"errors":[],"messages":[]}%

Thank you, I’ll figure something out to store this id.

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