Help with Deleting Subdomains via API

I’m currently testing Cloudflare API to manage subdomains, and I have a quick question.

I successfully created a subdomain using the API, but I’m struggling to find information on how to delete a subdomain through the API. I want to explore the API’s potential fully and would appreciate your guidance.

Could you please let me know if there’s a way to delete subdomains programmatically using the API? If so, could you share the API endpoint and any necessary steps?

Your help will be invaluable for my testing efforts!

List the DNS records (with the aim to get the ID for the record you want to delete)…

Then use the ID to delete the record…

I’m trying to delete a Cloudflare Workers subdomain through the API due to an error preventing the creation of a new subdomain. The error message I’m encountering is: “workers.api.error.account_has_subdomain.”

Issues Faced:

  • Unable to create a new Cloudflare Workers subdomain due to the mentioned error.
  • Attempts to list DNS records returned an empty result.
  • Efforts to delete the subdomain using the documented API endpoint (DELETE /accounts/{account_id}/workers/subdomain) resulted in a “method_not_allowed” error with the code “1001.”

Using the /accounts/{account_id}/workers/subdomain endpoint, I retrieved information about the existing subdomain. JSON output:

    "result": {
        "subdomain": "moyasuxin"
    "success": true,
    "errors": [],
    "messages": []

I’m reaching out to seek guidance on the correct method for deleting a Cloudflare Workers subdomain through the API and how to resolve the “method_not_allowed” error when attempting to delete the subdomain.

Additional Information:
Listing DNS records returned an empty result. JSON output:

    "result": [],
    "success": true,
    "errors": [],
    "messages": [],
    "result_info": {
        "page": 1,
        "per_page": 100,
        "count": 0,
        "total_count": 0,
        "total_pages": 1

Yeah, Internal API can replace the sub_domain but Public API isn’t able to. :frowning: