# Creating new topic by API - how do you know which topic ID to use?

**URL:** https://meta.discourse.org/t/creating-new-topic-by-api-how-do-you-know-which-topic-id-to-use/96633
**Category:** Support
**Created:** [September 7, 2018, 2:17pm UTC](https://meta.discourse.org/t/creating-new-topic-by-api-how-do-you-know-which-topic-id-to-use/96633 "2018-09-07T14:17:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![lazar\_gilbert](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@lazar\_gilbert](https://meta.discourse.org/u/lazar_gilbert)
#### Post date: [September 7, 2018, 2:17pm UTC](https://meta.discourse.org/t/creating-new-topic-by-api-how-do-you-know-which-topic-id-to-use/96633/1 "2018-09-07T14:17:36Z")

</div>

The api ([Discourse API Docs](https://docs.discourse.org/#tag/Posts%2Fpaths%2F~1posts.json%2Fpost)) states that new topics must specify a topic\_id integer, but how do I know the correct integer to use?

For example if I put 1,there already exists a topic with that integer. I could pick a random integer, but that seems a bad approach to take? Am I supposed to loop through all of the topics to find the next topic integer not in use?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 7, 2018, 2:18pm UTC](https://meta.discourse.org/t/creating-new-topic-by-api-how-do-you-know-which-topic-id-to-use/96633/2 "2018-09-07T14:18:52Z")

</div>

The `topic_id` is only required if you are adding a post to an existing topic. For a new topic, you do not need to include it in the request.

---

<div class="post-metadata">

### Author: ![mikechristopher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikechristopher/32/89135_2.png) [@mikechristopher](https://meta.discourse.org/u/mikechristopher)
#### Post date: [September 7, 2018, 2:22pm UTC](https://meta.discourse.org/t/creating-new-topic-by-api-how-do-you-know-which-topic-id-to-use/96633/3 "2018-09-07T14:22:39Z")

</div>

@david beat me to it

All you need if creating a new topic is the following:  
**title**  
**raw**  
**category** (category number if posting in a particular category)

As well as your api key and username

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 22, 2018, 5:12pm UTC](https://meta.discourse.org/t/creating-new-topic-by-api-how-do-you-know-which-topic-id-to-use/96633/4 "2018-09-22T17:12:34Z")

</div>

This topic was automatically closed after 14 days. New replies are no longer allowed.
