# Creating new topic in subcategory via API

**URL:** https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518
**Category:** Support
**Created:** [06.Апрель.2017 03:24:20 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518 "2017-04-06T03:24:20Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nordize](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nordize](https://meta.discourse.org/u/nordize)
#### Post date: [06.Апрель.2017 03:24:20 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518/1 "2017-04-06T03:24:20Z")

</div>

I tried using `&category=subcategory-slug` but it ends up in the `uncategorized` category. I also tried to use `&category=category-slug/subcategory-slug` and got the same thing. It works fine if it’s a main category. Is it possible to create a new topic in a subcategory? If yes, what’s the syntax?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [06.Апрель.2017 03:26:51 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518/2 "2017-04-06T03:26:51Z")

</div>

Assuming the API takes the same parameters as create topic via URL (no idea why it wouldn’t) - then you should be using the category name, not the slug.

Source:  
[https://meta.discourse.org/t/cannot-compose-a-pre-filled-topic-via-url-when-subcategory-has-topic-template/39941/2?u=jomaxro](https://meta.discourse.org/t/cannot-compose-a-pre-filled-topic-via-url-when-subcategory-has-topic-template/39941/2)

---

<div class="post-metadata">

### Author: ![nordize](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nordize](https://meta.discourse.org/u/nordize)
#### Post date: [06.Апрель.2017 09:49:05 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518/3 "2017-04-06T09:49:05Z")

</div>

I just wanted to reply to say that I tried the category name too and that failed too. It had spaces (I used the url encoded version with both `+` and `%20`) but now I renamed it to something without spaces and it works. I then renamed it back to something with spaces and it still works … sorry for wasting your time 😕

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [06.Апрель.2017 10:19:07 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518/4 "2017-04-06T10:19:07Z")

</div>

Based on the docs, the category parameter is an integer, you need to use the category id there.

> **[Discourse API Docs](https://docs.discourse.org/#tag/Topics%2Fpaths%2F~1posts%2Fpost)**

---

<div class="post-metadata">

### Author: ![nordize](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nordize](https://meta.discourse.org/u/nordize)
#### Post date: [06.Апрель.2017 12:48:01 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518/5 "2017-04-06T12:48:01Z")

</div>

It certainly worked with the category name (string) though.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [22.Май.2019 19:12:34 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518/6 "2019-05-22T19:12:34Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [22.Май.2019 20:12:10 UTC](https://meta.discourse.org/t/creating-new-topic-in-subcategory-via-api/60518/7 "2019-05-22T20:12:10Z")

</div>


