# Sets reply\_to when creating a message through the API?

**URL:** https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903
**Category:** Development
**Tags:** rest-api
**Created:** [February 18, 2018, 9:27pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903 "2018-02-18T21:27:41Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [February 18, 2018, 9:27pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/1 "2018-02-18T21:27:41Z")

</div>

Hi. Is there a way to specify the message ID to which a new message responds when we create this last one through Discourse API?

---

<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: [February 19, 2018, 8:13am UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/2 "2018-02-19T08:13:20Z")

</div>

I believe you should be able to use the key - **reply\_to\_post\_number** in your POST request

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

---

<div class="post-metadata">

### Author: ![Bertrand\_Gorge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bertrand_gorge/32/228856_2.png) [@Bertrand\_Gorge](https://meta.discourse.org/u/Bertrand_Gorge)
#### Post date: [May 5, 2022, 8:32am UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/3 "2022-05-05T08:32:49Z")

</div>

Hello, I allow myself to reopen this thread. I’m using the API right now to convert some custom conversation system to discourse, and I’m struggling with the replies.

I use the `/posts` API, with the `reply_to_post_number` parameter and the post does not show as a reply at all. I’ve checked that the `reply_to_post_number` matches the post\_number of the post above, to no avail.

I’ve tried reverse engineering the API, tried adding `nested_post` to the request as this was the main difference between my call and the one in the interface, but the result is still the same…

Note that the post created through the API does have the `reply_to_post_number` correctly set. It just doesn’t show up as such on the interface…

Thanks for any lead !

---

<div class="post-metadata">

### Author: ![greedNotGood](https://avatars.discourse-cdn.com/v4/letter/g/3da27b/32.png) [@greedNotGood](https://meta.discourse.org/u/greedNotGood)
#### Post date: [July 28, 2022, 9:12am UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/4 "2022-07-28T09:12:45Z")

</div>

OK, i just created an account because i had the same problem and found the solution!

Like Bertrand said; you can set the reply\_to\_post\_number all day long but in the UI it is not shown as a regular reply. When i tried to create a reply however in the same way but with my admin account it DID work! This indicated it had something to do with permissions.

I found out that if i changed the Security settings of the Category the post belonged to, so that the default Everyone group had all rights (so also Create rights which was unchecked by default for me) it now WORKS! Not sure why this right is needed as Create already works (i can create a post), and the Reply right was already checked but anyway… it WORKS 😃

---

<div class="post-metadata">

### Author: ![Gaurav\_Tewari](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gaurav_tewari/32/260621_2.png) [@Gaurav\_Tewari](https://meta.discourse.org/u/Gaurav_Tewari)
#### Post date: [October 16, 2022, 6:13pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/5 "2022-10-16T18:13:33Z")

</div>

Hi @greedNotGood @Bertrand_Gorge I’m building a project where I need to add a reply to a post via discourse api. I’m new to discourse, Can you help me with a curl request or some documentation for the same? Appreciate your help.

Gaurav T

---

<div class="post-metadata">

### Author: ![Bertrand\_Gorge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bertrand_gorge/32/228856_2.png) [@Bertrand\_Gorge](https://meta.discourse.org/u/Bertrand_Gorge)
#### Post date: [October 17, 2022, 1:47pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/6 "2022-10-17T13:47:37Z")

</div>

Hello @Gaurav_Tewari the documentation is here: [Discourse API Docs](https://docs.discourse.org/#tag/Posts)

You have curl samples at the top of this same page. Good luck !

---

<div class="post-metadata">

### Author: ![mkolar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mkolar/32/301202_2.png) [@mkolar](https://meta.discourse.org/u/mkolar)
#### Post date: [April 4, 2023, 12:02pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/7 "2023-04-04T12:02:42Z")

</div>

Hi all.

I’m trying to get a post created to show as a reply to another post, but as multiple people above, I’m not very successful.

I’m sending `reply_to_post_number` as one of the keys in the payload to `/posts.json`, with value taken from another posts `post_number`, but that is not doing anything. The category security settings are fully permissive to all users.

Interestingly the response changes when I use `reply_to_post_number` in the post request vs when I don’t. If I don’t send it with the request, `'reply_to_post_number': None,` will be present in the response, however, if I do send it with the request with an integer value pointing to previous post, the response doesn’t have that key whatsoever.

This seems totally undocumented, which I very much realize, but any help would be appreciated. Discourse API docs are of no help as it is not mentioned there at all.

thanks

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 4, 2023, 1:28pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/8 "2023-04-04T13:28:08Z")

</div>

I tried to reply to a post with the API and it works:

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/0/6/906b4ce164fae9e7f48d356928b67d551f838452.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/5/2/6/526aca53e8b0dd77c278f99592ae7d480cfb491c.png)

However, there is indeed missing info in [docs.discourse.org](http://docs.discourse.org). 🙂

If you’re willing to, you can also contribute to this documentation: [Contributing to the Discourse API documentation](https://meta.discourse.org/t/contribute-to-the-discourse-api-docs/56693)

---

<div class="post-metadata">

### Author: ![mkolar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mkolar/32/301202_2.png) [@mkolar](https://meta.discourse.org/u/mkolar)
#### Post date: [April 4, 2023, 3:15pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/9 "2023-04-04T15:15:15Z")

</div>

The strange thing is that I can do it from insomnia as well, or any any plain request, but when doing it from python (just using requests, not the python api), it doesn’t seem to work.

I just noticed that the data seems to be there but it’s not showing in the main view.

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/f/f/5ffc59786279f8aca7c8f6d5783c309473eef2e9.png)

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 4, 2023, 3:24pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/10 "2023-04-04T15:24:46Z")

</div>

> [@mkolar](#):
>
> I just noticed that the data seems to be there but it’s not showing in the main view.

Even in [safe mode](https://meta.discourse.org/t/53504?silent=true) (well, just to be sure…)?

What does `https://your-discourse.com/posts/{id}.json` (where `{id}` is the new post id) return?

Is there a `"reply_to_post_number"` key value?

I don’t think I can help further on this unfortunately and I never used Python, I’ll let real connaisseurs try to help you 🙂

Maybe pasting your script would give some clue?

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [April 4, 2023, 3:34pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/11 "2023-04-04T15:34:31Z")

</div>

It’s hard to tell from your example if this is the case, but if you reply to a post and your reply is the next post, we hide the _reply to post_ info in the UI.

---

<div class="post-metadata">

### Author: ![mkolar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mkolar/32/301202_2.png) [@mkolar](https://meta.discourse.org/u/mkolar)
#### Post date: [April 4, 2023, 3:54pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/12 "2023-04-04T15:54:53Z")

</div>

![Batman Facepalm GIF by WE tv](https://global.discourse-cdn.com/meta/original/4X/8/9/0/89007210c484d88585f946f25950bf063c628690.webp)

If there was a bigger facepalm, it would fit here. That is of course the issue and I just ended up testing on precisely the type of post that is next to it’s reply target. It makes perfect sense of course, just not obvious why it sometimes shows and sometimes it doesn’t.

Nevertheless the mystery is solved, thank you folks. Much appreciated.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 4, 2023, 4:02pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/13 "2023-04-04T16:02:10Z")

</div>

> [@mkolar](#):
>
> If there was a bigger facepalm, it would fit here.

If that can help you feel better, I think many people working at Discourse don’t know **all** features of the software 😁 (at least, this makes **me** feel better 😆)

---

<div class="post-metadata">

### Author: ![mkolar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mkolar/32/301202_2.png) [@mkolar](https://meta.discourse.org/u/mkolar)
#### Post date: [April 4, 2023, 4:05pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/14 "2023-04-04T16:05:08Z")

</div>

Oh I totally get that. I run a company maintaining and supporting a large open-source project. There comes a point where collective knowledge is the only way.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:36pm UTC](https://meta.discourse.org/t/sets-reply-to-when-creating-a-message-through-the-api/80903/15 "2024-06-08T12:36:43Z")

</div>

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