Skip to content

CreateGroup#

Postman Test

The method is intended for creating a group chat.

The method uses limits on the request rate per second.

Request#

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

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

To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Required Description
groupName string Yes Name of the new group chat. The maximum field length is 100 characters
chatIds array Yes List of identifiers of the group participants
type string No Type of the group being created.
Possible values: group (default), supergroup
messageAutoDeleteTime integer No Message auto-delete time in days. The allowed range is from 0 to 365. A value of 0 disables automatic deletion.

Request body example#

{
   "groupName": "Group created by Green API",
   "chatIds": [
    "10000000", 
    "10000001"
    ],
   "type": "supergroup"
}

Response#

Response fields#

Field Type Description
created boolean Flag that the group is created
chatId string Group chat identifier
groupInviteLink string Group invitation link

Response body example#

{
    "created": true,
    "chatId": "-10000000000000",
    "groupInviteLink": "https://t.me/+AbCdEfGfdbtjKlMnOp"
}

Errors#

For the list of errors common to all methods, see the Common errors section

HTTP code Error identifier Description
400 Bad Request
Validation failed
Validation error
500 Internal Server Error
Timed Out
A group is specified as one or more of the chatIds elements
500 Internal Server Error
bad-request
A number that has no Telegram account is specified as one or more of the chatIds elements

Code examples#

import requests

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

payload = {(
    "groupName": "Group created by GREEN-API", 
    "chatIds": ["10000000", "10000001"])
}
headers = {'Content-Type': 'application/json'}

response = requests.post(url, json=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": ["10000000", "10000001"]
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .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\":[\"10000000\",\"10000001\"]}";

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("/createGroup/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"groupName\":\"Group created by GREEN-API TEST\",\"chatIds\":[\"10000000\",\"10000001\"]}")
    .asString();

System.out.println(response);
Sub CreateGroup()
    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}}/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"":[""10000000"",""10000001""]}"

    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