SetGroupAdmin#
The method appoints a group chat participant as an administrator.
The method uses limits on the request rate per second.
Request#
To appoint a group chat participant as an administrator, you need to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/setGroupAdmin/{{apiTokenInstance}}
To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
chatId | string | Yes | Group chat identifier |
participantChatId | string | Yes | Identifier of the group participant being appointed as an administrator |
permissions | object | No | Object with administrator rights. If it is not passed, the default settings will be used |
Parameters of the permissions object:
| Parameter | Type | Description |
|---|---|---|
canManageChat | boolean | The right to manage the chat (access to the action log, granting other rights)true/false |
canChangeInfo | boolean | The right to change the group information (name, photo, description)true/false |
canPostMessages | boolean | The right to post messages (relevant for channels)true/false |
canEditMessages | boolean | The right to edit other users' messages (only for channels)true/false |
canDeleteMessages | boolean | The right to delete other users' messagestrue/false |
canInviteUsers | boolean | The right to invite users to the group by linktrue/false |
canRestrictMembers | boolean | The right to restrict (ban) userstrue/false |
canPinMessages | boolean | The right to pin messagestrue/false |
canManageTopics | boolean | The right to manage topics (only for forums)true/false |
canPromoteMembers | boolean | The right to add new administratorstrue/false |
canManageVideoChats | boolean | The right to manage video chatstrue/false |
canPostStories | boolean | The right to post stories on behalf of the grouptrue/false |
canEditStories | boolean | The right to edit other users' storiestrue/false |
canDeleteStories | boolean | The right to delete other users' storiestrue/false |
isAnonymous | boolean | Administrator anonymity (messages will be sent on behalf of the group, and the administrator will be hidden from the participant list)true/false |
Request body example#
Appointing a group chat participant as an administrator:
{
"chatId": "-10000000000000",
"participantChatId": "10000000",
"permissions": {
"canChangeInfo": true,
"canDeleteMessages": true,
"canRestrictMembers": true,
"canPinMessages": true,
"canPromoteMembers": false,
"isAnonymous": false
}
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
setGroupAdmin | boolean | Flag that the group participant is appointed as an administrator |
Response body example#
{
"setGroupAdmin": true
}
Errors#
For the list of errors common to all methods, see the Common errors section
| HTTP code | Error identifier | Description |
|---|---|---|
| 200 | failed to set group admin | The participant could not be appointed as an administrator |
| 200 | you have to be group admin to change settings | The number linked to the instance is not an administrator |
| 200 | no permission | The number linked to the instance cannot appoint administrators in the group |
| 200 | participant is not a group member | The specified number is not a member of the group |
| 200 | participant not found | chatId is specified incorrectly |
| 400 | Bad Request Validation failed | Validation error |
Code examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/setGroupAdmin/{{apiTokenInstance}}"
payload = {(
"chatId": "-10000000000000",
"participantChatId": "10000000")
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, json=payload)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/setGroupAdmin/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "-10000000000000",
"participantChatId": "10000000"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/setGroupAdmin/")
.append({{apiTokenInstance}});
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
var jsonBody = "{\"chatId\": \"-10000000000000\",\"participantChatId\": \"10000000\"}";
var requestEntity = new HttpEntity<>(jsonBody, headers);
var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/setGroupAdmin/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\"chatId\": \"-10000000000000\",\"participantChatId\": \"10000000\"}")
.asString();
System.out.println(response);
Sub SetGroupAdmin()
Dim url As String
Dim RequestBody As String
Dim http As Object
Dim response As String
' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
url = "{{apiUrl}}/waInstance{{idInstance}}/setGroupAdmin/{{apiTokenInstance}}"
RequestBody = "{""chatId"":""-10000000000000"",""participantChatId"":""10000000""}"
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/json"
.Send RequestBody
End With
response = http.responseText
Debug.Print response
' Outputting the answer to the desired cell
Range("A1").Value = response
Set http = Nothing
End Sub