Discourse API Documentation

Discourse API

Please view the Discourse API Documentation site for detailed info:


:warning: Deprecation Warning!

On April 6th, 2020 we dropped support for all non-HTTP header based authentication (excluding some rss, mail-receiver, and ics routes). This means that API requests that have an api_key and api_username in the query params or in the HTTP body of the request will soon stop working. Please see the example cURL request below for how to update your API requests to use the HTTP headers for authentication.

The Content-Type can be set to “application/x-www-form-urlencoded”, “multipart/form-data” or “application/json”.

Here is an example POST request via cURL:

curl -X POST "" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: discourse1" \
-F "name=89853c20-4409-e91a-a8ea-f6cdff96aaaa" \
-F "color=49d9e9" \
-F "text_color=f0fcfd"

Here is an example of what the API Documentation site looks like:

Consuming the API

You can consume the API using cURL commands, but we recommend using the discourse_api gem so that you can use Ruby.

Reverse engineering API endpoints

Not every endpoint is documented, but you can see an example API request and response for any endpoint by follow this guide:

API: Can I authenticate without putting the key in the URL?
Online User API?
Deeply integrating Discourse into website
How can I update trust level via SSO site
Discourse Add Group API
Do we have any API or way to get latest post details for a particular Topic in discourse?
Update current user fields through JavaScript?
API call to watch categories and tags
Using the Discourse API Ruby Gem
JSON API, get topics sorted by created_at
Use discourse_post_id to get single topic data from API
Quick Messages Plugin
Using the API, can't PUT to topic unless slug is on the URL
Using the API, can't PUT to topic unless slug is on the URL
Incoming webhooks (Incoming into Discourse)
Managing site customization via API
Discourse API Documentation Using RAML
Is it possible to mount a playable video game into a discourse forum?
How to upload bulk post
Interact with discourse from Python?
How to update profile information via API
Locations Plugin
Is there is any open API for getting similar topic in discourse?
What determines the order of frequent poster icons in the topic list?
Working with different needs in raw/cooked content
What is Discourse Blog built with?
What is correct aproach to update topic via ajax?
How to Create a Script to "Bulk Remove" from a Group?
Display username when login in banner
Possible for admins to create bookmarks for users?
API: Can I authenticate without putting the key in the URL?
Dev Category sidebar
RSS Feed Stopped Working?
Blocking user via API, returns 404
Which CMS for Discourse
How to get notifications via the API
Discourse API - Unable to query certain endpoints
Discourse Trust Levels for Discord
How to run Data Explorer queries with the Discourse API
WP Discourse plug in being odd
How to update mail-receiver to the release version
All API calls now getting "You are not permitted to view the requested resource"
Drupal SSO generates incorrect user sessions
Authentication using HTTP headers
'BAD CSRF' while creating a new post
403 Error during multiple API calls
Prometheus exporter plugin for Discourse
/admin/users/1/log_out route error
Official Single-Sign-On for Discourse (sso)
Delete user avatar by API
How do I send a topic id just created?
What is Discourse API?
Can Discourse API link with Obsidian?
Acess-Control-Allow-Headers CORS Error with API after updating discourse
Creating alternate user directory
Creating a new topic on behalf of a user
How can I update trust level via SSO site
Questions about support with hosted Discourse
Synchronizing Changes for SSO users
Shopify Integration
[Announce] Search & replace / batch process Discourse posts
API Error: You are not permitted to view the requested resource
Migrating from Jive Clearspace to Discourse
Can an admin change a user's email address?
How to get uploaded image url using the Discourse API?
Can't send PM via API (HTTPUnprocessableEntity 422)
How to contribute to the Discourse API Docs
Swagger, WADL or similar for the REST API?
Vague error from clicking on a tag link on this site
Work Around to posting
Discourse dislike Api?
A list of server-side functions for weekend/novice Discourse developers?
Api documentation on creating private forums
Seeding a new forum by creating users and content
How to implement Discourse with an already built Rails project

For the most up-to-date URL endpoints (without parameter details), check this file: discourse/routes.rb at master · discourse/discourse · GitHub


I’m trying to fetch all the replies from a given thread but for some reason, some of the replies doesn’t show up on the results. Here’s what I’m doing:

curl http://my-forum.com/t/thread-name/numeric-thread-id.json

Am I missing something? Can someone help me?

That gets you a block of 20 posts. For the next posts, try:


With the correct thread name, of course, otherwise you’re using two requests for every page.


Thanks @riking! That’s exactly what I was looking for.


Hello everyone, my first post in this forum.

I’m trying to get all posts in a topic with:

This works fine, except for that I only recieve the first 20 posts. I see the info about the rest of the posts under “stream”, but the posts themselves are missing. I can’t find a setting for this anywhere either. Any idea what I’m doing wrong? :slight_smile:

Running v1.6.0.beta2 +78 btw.

1 Like

You will need to pass in all the id’s from the “stream” as url parameters to this url:




I would still make sure you break them up in chunks of 20.

Also I recommend using the ruby discourse_api gem:

1 Like

Thank you!

So currently there’s no way to request a specific “page” not counting replies?

What I would like to do is get the last 5 posts, plus replies if there are any. But in “stream” i can’t see if a post is a reply or not, correct?

Can’t use the ruby gem I’m afraid, since our project is written in php. I’m stuck with curl. :slight_smile:

Nope. No paging, but the highest post_id’s on a topic should give you the latest ones (well I think there is a way to get paging, but it will return html, not json. Just browse your site with javascript disabled).

In the “stream” no, but in the json data for each post there are these fields:


which should help you get the reply info

If we really would like to have native support for this in the api, is there someone we could convince? Or hire?

My problem with this, if I’ve got this right, is that I don’t know which posts that are replies until I’ve retrieved them fully. So if I have a topic with 2000 posts I would have to get all 2000 posts to look for replies to the first post. Well, there is a reply_count so I could be lucky and stop the search when all is found, but worst case scenario is that I have to look through all posts. So it would be really nice to have an api call for this instead, right? :slight_smile:

Maybe, but that isn’t a super expensive call to do. You could probably fetch posts in batches of 100+ (or 2000 :scream:)

but you could probably just [quote=“mathias.kallberg, post:146, topic:22706”]
get the last 5 posts

and still get what you are looking for.

You could post a topic in the marketplace category here on meta and see if someone is willing to do it.

A quick question: Is there anything you’re not allowed to do via the Master API Key?

My college was trying to create users via the api, and didn’t succeed. After a bit if a struggle he’d created a second api key, for the system user, and got it working, but I wonder if that had anything to do with it? :slight_smile:

nope, the master API Key can do all the things.

What was the username he was using with the Master API Key? Even if you are using the Master API Key you still need to pass in a username with it.

His own username I think. So maybe his user didn’t have enough power, could that be it?

If he was using the Master API key though I don’t think it would matter, but if he was using just the api key for his user it would matter.

How can i get the original post? For example, its markdown version.
If i request https://meta.discourse.org/t/using-the-rest-api/21699.json i get only cooked versions of all posts.

Does adding ?include_raw=1 work for you? eg.


Discourse API Documentation


Okay, we finally have updated API Docs! Also, contributions are welcome.


Glad to finally see real API docs, thanks for that.

I have been having issues importing the Swagger/OpenAPI definition into Postman. I’ve also asked the Postman community about this. Has anyone done this successfully?

1 Like

I’m not sure about importing the swagger files, but you should be able to import the postman environment and collection json files into postman.