AddGroupParticipant#
The method adds a participant to a group chat.
The method uses limits on the request rate per second.
Request#
To add a participant to a group chat, you need to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/addGroupParticipant/{{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 | Chat identifier |
participantChatId | string | Yes | Identifier of the participant being added to the group chat. |
Request body example#
{
"chatId": "-10000000000000",
"participantChatId": "10000000"
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
addParticipant | boolean | Flag that the participant is added to the group chat |
reason | string | Reason for the refusal (only when addParticipant: false) |
Response body example#
{
"addParticipant": true
}
Errors#
For the list of errors common to all methods, see the Common errors section
| HTTP code | Error identifier | Description |
|---|---|---|
| 200 | "addParticipant": false | The specified number is already a member of the group |
| 200 | "addParticipant": false | You are not a member of the group |
| 400 | "addParticipant": false | participantChatId is specified incorrectly |
| 400 | Bad Request Validation failed | Validation error |
Code examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/addGroupParticipant/{{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}}/addGroupParticipant/{{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("/addGroupParticipant/")
.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("/addGroupParticipant/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\"chatId\": \"-10000000000000\",\"participantChatId\": \"10000000\"}")
.asString();
System.out.println(response);
Sub AddGroupParticipant()
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}}/addGroupParticipant/{{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