# How do I send a topic id just created?

**URL:** https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606
**Category:** Development
**Created:** [August 12, 2020, 9:33am UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606 "2020-08-12T09:33:42Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![slivo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slivo/32/186825_2.png) [@slivo](https://meta.discourse.org/u/slivo)
#### Post date: [August 12, 2020, 9:33am UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/1 "2020-08-12T09:33:42Z")

</div>

After creating a topic in a given category, I would like to send its topic ID automatically. How can I do it ?  
(My goal is to respond to the topic and I need to know his ID)

---

<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: [August 12, 2020, 2:00pm UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/2 "2020-08-12T14:00:33Z")

</div>

How are you creating the topic? If you’re using the API, it returns a load with the topic ID.

You might also take a step back and describe your whole problem and not just this solution

---

<div class="post-metadata">

### Author: ![slivo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slivo/32/186825_2.png) [@slivo](https://meta.discourse.org/u/slivo)
#### Post date: [August 13, 2020, 7:27am UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/3 "2020-08-13T07:27:28Z")

</div>

I would like to create topics in different ways, for example through a custom wizard. When user end the wizard then I know what is the id of the the created topic via completed wizard. I don’t know how to solve this logically best

---

<div class="post-metadata">

### Author: ![rishabh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rishabh/32/179446_2.png) [@rishabh](https://meta.discourse.org/u/rishabh)
#### Post date: [August 13, 2020, 7:43am UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/4 "2020-08-13T07:43:33Z")

</div>

If you plan to use the [Discourse API](https://meta.discourse.org/t/discourse-api-documentation/22706) for this, the response will give you the ID automatically:

> [@pfaffman](#):
>
> If you’re using the API, it returns a load with the topic ID.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 13, 2020, 7:54am UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/5 "2020-08-13T07:54:26Z")

</div>

How about leveraging the event system?

eg

> [@Post created is fired when topic created](https://meta.discourse.org/t/post-created-is-fired-when-topic-created/84725):
>
> Working with the internal event hooks and I noticed, when the topic\_created event triggers so does post\_created. For the initial topic post, wouldn’t the assumption be that a post was created as well? Is there a reason why they both would fire at the same time? It seems redundant to have both fire at the same time, especially because you cannot create a topic without an inital post. Ex: DiscourseEvent.on(:topic\_created) do |topic| puts "New Topic" end DiscourseEvent.on(:post\_created) do …

---

<div class="post-metadata">

### Author: ![slivo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slivo/32/186825_2.png) [@slivo](https://meta.discourse.org/u/slivo)
#### Post date: [August 13, 2020, 11:35am UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/6 "2020-08-13T11:35:58Z")

</div>

But we’re talking about the POST or GET request and to which endpoint ?

---

<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: [August 13, 2020, 3:59pm UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/7 "2020-08-13T15:59:56Z")

</div>

> [@slivo](#):
>
> I would like to create topics in different ways,

Then there will be different answers.

> [@slivo](#):
>
> for example through a custom wizard

Then that’s what you should be asking about.

So maybe your question is something like “how do I do X with a topic created with the custom Wizard plugin?” I suspect that the answer doesn’t necessarily even involve getting the `topic_id`.

---

<div class="post-metadata">

### Author: ![slivo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slivo/32/186825_2.png) [@slivo](https://meta.discourse.org/u/slivo)
#### Post date: [August 13, 2020, 7:16pm UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/8 "2020-08-13T19:16:41Z")

</div>

> [@pfaffman](#):
>
> doesn’t necessarily even involve getting the `topic_id` .

What do you mean by that ?

---

<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: [August 13, 2020, 7:18pm UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/9 "2020-08-13T19:18:53Z")

</div>

I mean that if you describe the actual problem that you are trying to solve rather than a piece of your way of solving it, you might be able to get help. If you are trying to accomplish something with the Custom Wizard plugin, then you should ask how to solve that problem.

---

<div class="post-metadata">

### Author: ![slivo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slivo/32/186825_2.png) [@slivo](https://meta.discourse.org/u/slivo)
#### Post date: [August 13, 2020, 7:27pm UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/10 "2020-08-13T19:27:31Z")

</div>

I think that every problem can be solved in many ways so I don’t know why I should limit it to this plugin. I guess it is better to find / learn a potentially universal solution?

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [August 13, 2020, 7:40pm UTC](https://meta.discourse.org/t/how-do-i-send-a-topic-id-just-created/160606/11 "2020-08-13T19:40:19Z")

</div>

> [@slivo](#):
>
> After creating a topic in a given category, I would like to send its topic ID automatically. How can I do it ?  
> (My goal is to respond to the topic and I need to know his ID)

Hi @silvo,

More than likely you will need to extend `class TopicCreator` and add a method to “send you” (you will need to define exactly what “send you” means) the topic id of a topic when a new topic is created.

> <https://github.com/discourse/discourse/blob/main/lib/topic_creator.rb>

Note: You could also extend the class(es) which calls the TopicCreator class, but hopefully you get the idea.

Hope this helps.
