Using private messages api

We use discourse as a backend to power forum and messaging tools on a platform. For retrieving private messages via the api, we would (on our backend) request /topics/private-messages/MY_USERNAME.json and /topics/private-messages-sent/MY_USERNAME.json, and merge the lists on topic id.

Since discourse/discourse#9029, this is not possible, because every private message has its own topic. Is there a recommended method of syncing up sent and received private messages so that they can be shown as threads?

1 Like

I’m not totally sure I follow what you are trying to accomplish? I think because of the overloaded term “Private Message” (post or topic) and threads.

topics/private-messages/MY_USERNAME.json also includes sent so I’m not sure why they need to be synced up?

Every PM is a Topic. A topic has an ID and a topic contains many posts.

Both of those endpoints return a topic_list with an array of topics.

topic_list: {
  topics: [
    {id: 1, ...},
	{id: 2, ...}
  ]
}

That you should be able to sync up by id?

Then to get all the posts that belong to a specific topic you can visit /t/TOPIC_ID.json