LeaveGroup#
The method makes the current account user leave the group chat.
Request#
To leave a group chat, you have to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/leaveGroup/{{apiTokenInstance}} For apiUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.
Request parameters#
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
groupId | string | Yes | Group chat Id, which you'd like to leave. |
Request body example#
{ "groupId": "79876543210-1587570015@g.us" } Response#
Response parameters#
| Parameter | Type | Description |
|---|---|---|
leaveGroup | boolean | Leave group flag |
removeAdmin | boolean | Leave group flag (if you are the administrator of the group) |
Response body example#
{ "leaveGroup": true } { "removeAdmin": true } LeaveGroup errors#
For a list of errors common to all methods, refer to Common errors section
| HTTP code | Error identifier | Description |
|---|---|---|
| 400 | Bad Request Validation failed | Validation error |
Request examples#
import requests url = "{{apiUrl}}/waInstance{{idInstance}}/leaveGroup/{{apiTokenInstance}}" payload = {( "groupId": "11011234567@g.us") } headers = { 'Content-Type': 'application/json' } response = requests.post(url, json=payload) print(response.text.encode('utf8')) curl --location '{{apiUrl}}/waInstance{{idInstance}}/leaveGroup/{{apiTokenInstance}}' \ --header 'Content-Type: application/json' \ --data-raw '{ "groupId": "112121212121212@g.us" }' var restTemplate = new RestTemplate(); var requestUrl = new StringBuilder(); requestUrl .append({{apiUrl}}) .append("/waInstance").append({{idInstance}}) .append("/leaveGroup/") .append({{apiTokenInstance}}); var headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); var jsonBody = "{\"groupId\": \"11111111111111111@g.us\"}"; 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("/leaveGroup/") .append({{apiTokenInstance}}); var response = Unirest.post(requestUrl.toString()) .header("Content-Type", "application/json") .body("{\"groupId\": \"11111111111111111@g.us\"}") .asString(); System.out.println(response); Sub LeaveGroup() 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}}/leaveGroup/{{apiTokenInstance}}" ' groupId - ID of the group chat you want to leave RequestBody = "{""groupId"":""120123400367448864@g.us""}" 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