Unmute user via REST API

I would like to make a simple newsletter by creating read-only private group. So only owner or moderator can post messages and invite/kick members.

I have successfuly created all of the above through REST API, but the issue is that the user/owner of the group is muted by default and I cannot find any way how to unmute him through the REST API.

I tried to call slash command through API by posting message “/unmute @groupowner123xyz”, but this does not really execute the command, it just posts the message to the chat without any impact to the user.

Is there any way how to do it through API ? Bellow is the request/response for posting slash command for unmute.

REQUEST:
POST https://localhost:8004/api/v1/chat.postMessage
Content-Type: application/json
X-Auth-Token: t-DG0hrb8Src6DpkoZKI_wvBFD8k_iQMyC-nUAu6pl2
X-User-Id: tbzjo8HJ2wdnA7afY

{“roomId”:“PEczQnwKeYpLymREa”,“channel”:"#group123",“text”:"/unmute @groupowner123xyz"}

RESPONSE:
Http-Code: 200
Date: Fri, 29 Dec 2017 14:05:34 GMT
Server: Apache/2.4.18 (Ubuntu)
Access-Control-Allow-Origin: *
X-Instance-Id: kxz6KBsJdNcrg9mdk
Cache-Control: no-store
Pragma: no-cache
Content-Type: application/json
Vary: Accept-Encoding
Connection: close

{
“ts”: 1514556334324,
“channel”: “#group123”,
“message”: {
“alias”: “”,
“msg”: “/unmute @groupowner123xyz”,
“parseUrls”: true,
“groupable”: false,
“ts”: “2017-12-29T14:05:34.314Z”,
“u”: {
"_id": “tbzjo8HJ2wdnA7afY”,
“username”: “admin”,
“name”: “admin”
},
“rid”: “PEczQnwKeYpLymREa”,
“mentions”: [
{
"_id": “axT5JnN7ax6bNonEf”,
“username”: “groupowner123xyz”
}
],
“channels”: [],
"_updatedAt": “2017-12-29T14:05:34.319Z”,
"_id": “vDK38KEhrfuzwpGuZ”
},
“success”: true
}

1 Like

When you call chat.postMessage its not going through command processors.

You can now actually get and execute slash commands as of a recent release. I believe they were added in 0.60.0

We need to get this over into documentation. But here’s how to use it: https://github.com/RocketChat/Rocket.Chat/blob/master/packages/rocketchat-api/server/v1/commands.js#L47

Hit commands.run with payload of something like:

{ command: 'unmute', params: '@groupowner123xyz', roomId: 'PEczQnwKeYpLymREa' }

Of course this is really just a work around.

I’m not aware of a mute or unmute via rest api. So I would recommend opening an issue to request it be added

1 Like

Thanks a lot, it works exactly as expected.

I have created the REST API docs and made a pull request already.
https://github.com/RocketChat/docs/pull/494

PR approved and document live: https://rocket.chat/docs/developer-guides/rest-api/commands/

You rock!

1 Like

Thanks, I have also added the links to the toc: https://github.com/RocketChat/docs/pull/495

1 Like