Need to create chat channels via API

Hi,

Our app hosts hundreds of communities and each of them need a chat channel. Currently we can automatically create categories and user groups via the API which is great, but we are forced to create every chat channel manually as there seems to be no API endpoint for this, which is a major strain for us.

Are there any plans to include chat channel creation in the API? That would be incredibly helpful as it’s our biggest issue with our Discourse integration right now

Thank you very much in advance!

Hmm, are you sure there is no API endpoint?

I thought this was it:

 Category channel — POST /chat/api/channels

 Defined at plugins/chat/config/routes.rb:9 → Chat::Api::ChannelsController#create
  (plugins/chat/app/controllers/chat/api/channels_controller.rb:60).

Thank you so much @chapoi ! :slight_smile:

For anyone else trying to do this, after some digging around I found out that these are the parameters needed to create a chat channel, in particular note that the category id needs to be in “chatable_id”:

curl -i -X POST “YOUR_DISCOURSE_URL”
-H “Content-Type: application/json”
-H “Api-Key: YOUR_API”
-H “Api-Username: API_USERNAME”
-d ‘{
“channel”: {
“chatable_id”: CATEGORY_ID,
“name”: “Chat name”,
“slug”: “chat-slug”,
“description”: “Chat description”,
“auto_join_users”: true,
“threading_enabled”: true
}
}’

Great, glad I could help!

If the issue is resolved, please mark the post that helped you as the solution so others can find the answer too.