# API support for deleting categories?

**URL:** https://meta.discourse.org/t/api-support-for-deleting-categories/204046
**Category:** Development
**Tags:** rest-api
**Created:** [September 20, 2021, 7:25pm UTC](https://meta.discourse.org/t/api-support-for-deleting-categories/204046 "2021-09-20T19:25:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Andy\_Price](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andy_price/32/233924_2.png) [@Andy\_Price](https://meta.discourse.org/u/Andy_Price)
#### Post date: [September 20, 2021, 7:25pm UTC](https://meta.discourse.org/t/api-support-for-deleting-categories/204046/1 "2021-09-20T19:25:46Z")

</div>

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](https://docs.discourse.org/#tag/Categories), but I did find [this promising post](https://review.discourse.org/t/add-api-to-delete-category-197/11378) 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?

Thanks,  
Andy

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 20, 2021, 9:28pm UTC](https://meta.discourse.org/t/api-support-for-deleting-categories/204046/2 "2021-09-20T21:28:28Z")

</div>

> [@Andy\_Price](#):
>
> 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](https://docs.discourse.org/#tag/Categories), but I did find [this promising post](https://review.discourse.org/t/add-api-to-delete-category-197/11378) that indicates that a PR with new functionality for this wa

The PR that you have linked to adds a `delete_category` method to the [Discourse API gem](https://github.com/discourse/discourse_api). 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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 20, 2021, 10:15pm UTC](https://meta.discourse.org/t/api-support-for-deleting-categories/204046/3 "2021-09-20T22:15:21Z")

</div>

> [@Andy\_Price](#):
>
> delete a category, I see that it is not listed on the [API documentation page here](https://docs.discourse.org/#tag/Categories),

The better place to look is almost always [How to reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576).

---

<div class="post-metadata">

### Author: ![Andy\_Price](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andy_price/32/233924_2.png) [@Andy\_Price](https://meta.discourse.org/u/Andy_Price)
#### Post date: [September 20, 2021, 11:24pm UTC](https://meta.discourse.org/t/api-support-for-deleting-categories/204046/4 "2021-09-20T23:24:53Z")

</div>

Awesome, thank you both!

@simon thanks for the detailed reply, I see now that I was mistaking that repo for the discourse API repo.

This explanation is super helpful, thank you!
