Andy_Price asks about API support for deleting categories, noting it’s not listed in the official documentation but mentions a merged PR. simon clarifies that a delete_category method exists in the Discourse API gem and that a DELETE request to /categories/<category_id> can be used directly via the API. They note that deletion fails if the category contains topics other than the initial “About” topic, requiring topics to be recategorized first. pfaffman suggests referring to the guide on reverse-engineering the Discourse API for better insights. Andy_Price thanks both for the clarification.
I am working with the API to build an integration with a Drupal site. One function I need to add is giving users the ability to delete a category, I see that it is not listed on the API documentation page here, but I did find this promising post that indicates that a PR with new functionality for this was merged. The PR didn’t indeivcate what the uri for the new functionality would be.
Wondering if anyone knows if this is available now and if so what uri I can use to access it?
The PR that you have linked to adds a delete_category method to the Discourse API gem. If you are using the Discourse API gem for your API calls, you will be able to use that method. If you are not using the Discourse API gem, you can delete a category through the API by making a DELETE request to your site’s /categories/<category_id> route. Set <category_id> to the id of the category you are wanting to delete.
I believe that either with the API gem, or with the DELETE request made to /categories/<category_id>, an error will be returned if the category has any topics in it other than the initial “About” topic that was created when you first created the category. You need to recategorize a category’s topics before deleting the category.