Discourse API Documentation
This page contains the documentation on how to use Discourse through API calls.
Note: For any endpoints not listed you can follow the guide to figure out how to use an API endpoint.
Request Content-Type
The Content-Type for POST and PUT requests can be set to application/x-www-form-urlencoded,
multipart/form-data, or application/json.
Endpoint Names and Response Content-Type
Most API endpoints provide the same content as their HTML counterparts. For example
the URL /categories serves a list of categories, the /categories.json API provides the
same information in JSON format.
Instead of sending API requests to /categories.json you may also send them to /categories
and add an Accept: application/json header to the request to get the JSON response.
Sending requests with the Accept header is necessary if you want to use URLs
for related endpoints returned by the API, such as pagination URLs.
These URLs are returned without the .json prefix so you need to add the header in
order to get the correct response format.
Authentication
Some endpoints do not require any authentication, pretty much anything else will require you to be authenticated.
To become authenticated you will need to create an API Key from the admin panel.
Once you have your API Key you can pass it in along with your API Username as an HTTP header like this:
and this is how POST requests will look:
Boolean values
If an endpoint accepts a boolean be sure to specify it as a lowercase
true or false value unless noted otherwise.
curl -X GET "http://127.0.0.1:3000/admin/users/list/active.json" \-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \-H "Api-Username: system"curl -X POST "http://127.0.0.1:3000/categories" \-H "Content-Type: multipart/form-data;" \-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \-H "Api-Username: system" \-F "name=89853c20-4409-e91a-a8ea-f6cdff96aaaa" \-F "color=49d9e9" \-F "text_color=f0fcfd"- Homepage
- https://api.apis.guru/v2/specs/discourse.local/latest.json
- Provider
- discourse.local
- OpenAPI version
- 3.1.0
- Spec (JSON)
- https://api.apis.guru/v2/specs/discourse.local/latest/openapi.json
- Spec (YAML)
- https://api.apis.guru/v2/specs/discourse.local/latest/openapi.yaml
Tools (86)
Extracted live via the executor SDK.
-
backups.createBackupCreate backup
-
backups.downloadBackupDownload backup
-
backups.getBackupsList backups
-
backups.sendDownloadBackupEmailSend download backup email
-
badges.adminListBadgesList badges
-
badges.createBadgeCreate badge
-
badges.deleteBadgeDelete badge
-
badges.listUserBadgesList badges for a user
-
badges.updateBadgeUpdate badge
-
categories.createCategoryCreates a category
-
categories.getCategoryShow category
-
categories.listCategoriesRetrieves a list of categories
-
categories.listCategoryTopicsList topics
-
categories.updateCategoryUpdates a category
-
groups.addGroupMembersAdd group members
-
groups.createGroupCreate a group
-
groups.deleteGroupDelete a group
-
groups.getGroupGet a group
-
groups.listGroupMembersList group members
-
groups.listGroupsList groups
-
groups.removeGroupMembersRemove group members
-
groups.updateGroupUpdate a group
-
invites.createInviteCreate an invite
-
notifications.getNotificationsGet the notifications that belong to the current user
-
notifications.markNotificationsAsReadMark notifications as read
-
posts.createTopicPostPmCreates a new topic, a new post, or a private message
-
posts.deletePostdelete a single post
-
posts.getPostRetrieve a single post
-
posts.listPostsList latest posts across topics
-
posts.lockPostLock a post from being edited
-
posts.performPostActionLike a post and other actions
-
posts.postRepliesList replies to a post
-
posts.updatePostUpdate a single post
-
privateMessages.getUserSentPrivateMessagesGet a list of private messages sent for a user
-
privateMessages.listUserPrivateMessagesGet a list of private messages for a user
-
search.getSearchJsonSearch for a term
-
site.getSiteCan be used to fetch all categories and subcategories
-
tags.createTagGroupCreates a tag group
-
tags.getTagGet a specific tag
-
tags.getTagGroupGet a single tag group
-
tags.listTagGroupsGet a list of tag groups
-
tags.listTagsGet a list of tags
-
tags.updateTagGroupUpdate tag group
-
topics.bookmarkTopicBookmark topic
-
topics.createTopicTimerCreate topic timer
-
topics.getSpecificPostsFromTopicGet specific posts from a topic
-
topics.getTopicGet a single topic
-
topics.getTopicByExternalIdGet topic by external_id
-
topics.inviteToTopicInvite to topic
-
topics.listLatestTopicsGet the latest topics
-
topics.listTopTopicsGet the top topics filtered by period
-
topics.removeTopicRemove a topic
-
topics.setNotificationLevelSet notification level
-
topics.updateTopicUpdate a topic
-
topics.updateTopicStatusUpdate the status of a topic
-
topics.updateTopicTimestampUpdate topic timestamp
-
uploads.abortMultipartThis endpoint aborts the multipart upload initiated with /create-multipart. This should be used when cancelling the upload. It does not matter if parts were already uploaded into the external storage provider.
You must have the correct permissions and CORS settings configured in your external provider. We support AWS S3 as the default. See:
.
An external file store must be set up and
enable_direct_s3_uploadsmust be set to true for this endpoint to function. -
uploads.batchPresignMultipartPartsMultipart uploads are uploaded in chunks or parts to individual presigned URLs, similar to the one generated by /generate-presigned-put. The part numbers provided must be between 1 and 10000. The total number of parts will depend on the chunk size in bytes that you intend to use to upload each chunk. For example a 12MB file may have 2 5MB chunks and a final 2MB chunk, for part numbers 1, 2, and 3.
This endpoint will return a presigned URL for each part number provided, which you can then use to send PUT requests for the binary chunk corresponding to that part. When the part is uploaded, the provider should return an ETag for the part, and this should be stored along with the part number, because this is needed to complete the multipart upload.
You must have the correct permissions and CORS settings configured in your external provider. We support AWS S3 as the default. See:
.
An external file store must be set up and
enable_direct_s3_uploadsmust be set to true for this endpoint to function. -
uploads.completeExternalUploadCompletes an external upload initialized with /get-presigned-put. The file will be moved from its temporary location in external storage to a final destination in the S3 bucket. An Upload record will also be created in the database in most cases.
If a sha1-checksum was provided in the initial request it will also be compared with the uploaded file in storage to make sure the same file was uploaded. The file size will be compared for the same reason.
You must have the correct permissions and CORS settings configured in your external provider. We support AWS S3 as the default. See:
.
An external file store must be set up and
enable_direct_s3_uploadsmust be set to true for this endpoint to function. -
uploads.completeMultipartCompletes the multipart upload in the external store, and copies the file from its temporary location to its final location in the store. All of the parts must have been uploaded to the external storage provider. An Upload record will be completed in most cases once the file is copied to its final location.
You must have the correct permissions and CORS settings configured in your external provider. We support AWS S3 as the default. See:
.
An external file store must be set up and
enable_direct_s3_uploadsmust be set to true for this endpoint to function. -
uploads.createMultipartUploadCreates a multipart upload in the external storage provider, storing a temporary reference to the external upload similar to /get-presigned-put.
You must have the correct permissions and CORS settings configured in your external provider. We support AWS S3 as the default. See:
.
An external file store must be set up and
enable_direct_s3_uploadsmust be set to true for this endpoint to function. -
uploads.createUploadCreates an upload
-
uploads.generatePresignedPutDirect external uploads bypass the usual method of creating uploads via the POST /uploads route, and upload directly to an external provider, which by default is S3. This route begins the process, and will return a unique identifier for the external upload as well as a presigned URL which is where the file binary blob should be uploaded to.
Once the upload is complete to the external service, you must call the POST /complete-external-upload route using the unique identifier returned by this route, which will create any required Upload record in the Discourse database and also move file from its temporary location to the final destination in the external storage service.
You must have the correct permissions and CORS settings configured in your external provider. We support AWS S3 as the default. See:
.
An external file store must be set up and
enable_direct_s3_uploadsmust be set to true for this endpoint to function. -
users.adminGetUserGet a user by id
-
users.adminListUsersGet a list of users
-
users.anonymizeUserAnonymize a user
-
users.changePasswordChange password
-
users.createUserCreates a user
-
users.deleteUserDelete a user
-
users.getUserGet a single user by username
-
users.getUserEmailsGet email addresses belonging to a user
-
users.getUserExternalIdGet a user by external_id
-
users.getUserIdentiyProviderExternalIdGet a user by identity provider external ID
-
users.listUserActionsGet a list of user actions
-
users.listUsersPublicGet a public list of users
-
users.logOutUserLog a user out
-
users.refreshGravatarRefresh gravatar
-
users.sendPasswordResetEmailSend password reset email
-
users.silenceUserSilence a user
-
users.suspendUserSuspend a user
-
users.updateAvatarUpdate avatar
-
users.updateEmailUpdate email
-
users.updateUserUpdate a user
-
users.updateUsernameUpdate username
-
openapi.previewSpecPreview an OpenAPI document before adding it as a source
-
openapi.addSourceAdd an OpenAPI source and register its operations as tools