UpdateGroupSettings#
Beta version
The functionality is in beta mode. Functions can be changed and may also work unstably.
The method is used to change the group settings.
Request#
To change the group settings, you need to make a request to the address:
POST
{{apiUrl}}/waInstance{{idInstance}}/updateGroupSettings/{{apiTokenInstance}}
For apiUrl
, idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Request parameters#
Parameter | Type | Mandatory | Description |
---|---|---|---|
groupId | string | Yes | Chat Id |
allowParticipantsEditGroupSettings | boolean | No | Allow members to change group settings. This includes the group name, picture, and description, the disappearing message timer, and the settings for saving and pinning messages. Possible values - true , false |
allowParticipantsSendMessages | boolean | No | Allow members to send messages to the group Possible values - true , false |
Note
If the group chat settings are already set to the required value, then the settings will not change.
You can find out about the change in the group chat settings using the method GetGroupData
Request body example#
Changing group settings:
{
"groupId": "1234567890123@g.us",
"allowParticipantsEditGroupSettings": true,
"allowParticipantsSendMessages": true
}
Response#
Response parameters#
Parameter | Type | Description |
---|---|---|
updateGroupSettings | boolean | Group settings change flag |
reason | string | Reason for request error (appears only when updateGroupSettings == false ) |
Response body example#
{
"updateGroupSettings": false, // flag of successful request application
"reason": "..." // reason for request error (appears only when updateGroupSettings == false)
}
UpdateGroupSettings errors#
For a list of errors common to all methods, refer to Common errors section
HTTP code | Error Id | Description |
---|---|---|
200 | "updateGroupSettings" false , "reason": "NOT_ENOUGH_RIGHTS" | Invalid groupId value |
200 | "updateGroupSettings" false , "reason": "FORBIDDEN" | The number was excluded from the group |
200 | "updateGroupSettings" false , "reason": "NOT_FOUND" | The specified group is not in the list of number's groups |
200 | "updateGroupSettings" false , "reason": "NO_SETTINGS_TO_UPDATE" | The allowParticipantsEditGroupSettings and allowParticipantsSendMessages fields are not specified |
400 | Bad Request Validation failed | Invalid groupId value |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/updateGroupSettings/{{apiTokenInstance}}"
payload = {
"groupId": "1234567890123@g.us",
"allowParticipantsEditGroupSettings": true,
"allowParticipantsSendMessages": true
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/waInstance%7B%7BidInstance%7D%7D/updateGroupSettings/%7B%7BapiTokenInstance%7D%7D',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"groupId": "1234567890123@g.us",
"allowParticipantsEditGroupSettings": true,
"allowParticipantsSendMessages": true
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
curl --location -g --request POST '/waInstance{{idInstance}}/updateGroupSettings/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"groupId": "1234567890123@g.us",
"allowParticipantsEditGroupSettings": true,
"allowParticipantsSendMessages": true
}'
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("/waInstance{{idInstance}}/updateGroupSettings/{{apiTokenInstance}}")
.header("Content-Type", "application/json")
.body("{\r\n \"groupId\": \"1234567890123@g.us\",\r\n \"allowParticipantsEditGroupSettings\": true,\r\n \"allowParticipantsSendMessages\": true\r\n}")
.asString();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "/waInstance%7B%7BidInstance%7D%7D/updateGroupSettings/%7B%7BapiTokenInstance%7D%7D"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"groupId": "1234567890123@g.us",`+"
"+`
"allowParticipantsEditGroupSettings": true`+"
"+`
"allowParticipantsSendMessages": true`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}