Skip to content

CreateGroup#

The method is aimed for creating a group chat. When creating a group, it is required to simulate human work. It is required to create a group no more often than 1 group every 5 minutes.

Request#

To create a group chat, you have to execute a request at:

POST {{APIUrl}}/waInstance{{idInstance}}/createGroup/{{apiTokenInstance}}

For APIUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Request parameters#

Parameter Type Mandatory Description
groupName string Yes New group chat name. The maximum field length is 100 characters
chatIds array Yes Collection of group participants Ids

Request body example#

{
    "groupName": "Group created by Green API",
    "chatIds": [
        "79001234568@c.us",
        "79001234569@c.us"
    ]
}

Response#

Response parameters#

Parameter Type Description
created boolean Group creation flag
chatId string Group chat Id
groupInviteLink string Group invitation link

Response body example#

{
    "created": true,
    "chatId": "11001234567-1587570015@g.us",
    "groupInviteLink": "https://chat.whatsapp.com/xxxxxxxxxxxxxxxxxxxxxx"
}

CreateGroup errors#

For a list of errors common to all methods, refer to Common errors section

HTTP code Description
500 When using the CreateGroup method, the system may return an error. This error is returned by WhatsApp, it restricts the user to create a group. Try to create a group from a mobile device, you will get a warning: "Failed to create a Test group because you created too many groups very quickly. Try again later."

Request examples#

import requests

url = "{{APIUrl}}/waInstance{{idInstance}}/createGroup/{{apiTokenInstance}}"

payload = "{\r\n\t\"groupName\": \"Group created by Green API\",\r\n    \"chatIds\": [\r\n        \"11001234567@c.us\",\r\n        \"79001234568@c.us\"\r\n    ]\r\n}\r\n"
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
curl --location '{{APIUrl}}/waInstance{{idInstance}}/createGroup/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "groupName": "Group created by Green API TEST",
    "chatIds": [
        "79888888234@c.us",
        "76567666543@c.us"
    ]
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/createGroup/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

var jsonBody = "{\"groupName\":\"Group created by Green API TEST\",\"chatIds\":[\"79888888234@c.us\",\"76567666543@c.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("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/createGroup/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"groupName\":\"Group created by Green API TEST\",\"chatIds\":[\"79888888234@c.us\",\"76567666543@c.us\"]}")
    .asString();

System.out.println(response);
Sub CreateGroup()
    Dim url As String
    Dim RequestBody As String
    Dim http As Object
    Dim response As String

    ' The idInstance and apiTokenInstance values are available in your account, double brackets must be removed
    url = "{{APIUrl}}/waInstance{{idInstance}}/createGroup/{{apiTokenInstance}}"

    ' groupName is the name of the new group chat, chatIds is a collection of group member IDs
    RequestBody = "{""groupName"":""Group created by Green API"",""chatIds"":[""79001234568@c.us"",""79001234569@c.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