CreateInstance#
The method is intended for creating an instance on a partner account.
After an instance is created without settings, the default settings will be disabled.
Request#
To create an account instance on behalf of a partner, you need to execute a POST request at:
POST
{{partnerApiUrl}}/partner/createInstance/{{partnerToken}}
Request parameters
The partnerApiUrl and partnerToken parameters are specified in the Profile section of the console.

Request parameters#
Parameters may be specified selectively. At least one parameter must be specified.
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | Instance name specified in the console |
webhookUrl | string | No | URL for sending webhooks |
webhookUrlToken | string | No | Token for connecting to your webhook server |
delaySendMessagesMilliseconds | integer | No | Delay between sending outgoing messages Value range: from 500 ms (0.5 seconds) to 300000 ms (5 minutes) |
markIncomingMessagesReaded | string | No | Mark incoming messages as read (yes / no), no by default |
markIncomingMessagesReadedOnReply | string | No | Mark incoming messages as read when a message is sent to the chat (yes, no), no by default |
outgoingWebhook | string | No | Receive notifications about the statuses of sent messages (yes / no), no by default |
outgoingMessageWebhook | string | No | Receive notifications about messages sent from the phone, the web and desktop versions (yes / no), no by default |
outgoingAPIMessageWebhook | string | No | Receive notifications about messages sent from the API (yes / no), no by default |
stateWebhook | string | No | Receive notifications about changes in the instance authorization state (yes / no), no by default |
incomingWebhook | string | No | Receive notifications about incoming messages and files (yes / no), no by default |
editedMessageWebhook | string | No | Receive notifications when messages are edited by the correspondent, possible values: yes, no |
deletedMessageWebhook | string | No | Receive notifications when messages are deleted by the correspondent, possible values: yes, no |
Request body example#
{
"name": "Vasilisa the Wise",
"webhookUrl": "https://mysite.com/webhook/green-api/",
"webhookUrlToken": "f93537eb3e8fed66847b5bd",
"delaySendMessagesMilliseconds": 1000,
"markIncomingMessagesReaded": "no", // The notification is temporarily not working.
"markIncomingMessagesReadedOnReply": "no", // The notification is temporarily not working.
"outgoingAPIMessageWebhook": "yes",
"outgoingWebhook": "yes",
"outgoingMessageWebhook": "yes",
"incomingWebhook": "yes",
"stateWebhook": "no",
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
apiTokenInstance | string | API token of the account instance |
apiUrl | string | Link to the API host |
idInstance | integer | Account instance identifier. A uint64 value, 10 digits |
mediaUrl | string | Link to the API host for sending files |
typeInstance | string | Messenger type for the account instance |
The field takes the value telegram for the Telegram messenger | ||
The field takes the value whatsapp - for the WhatsApp messenger | ||
The field takes the value v3 for the MAX messenger |
Response body example#
{
"apiTokenInstance": "abcdef12345fghij67890klmno09876pqrstu54321vwxyz",
"apiUrl": "https://api.green-api.com/",
"idInstance": 4100000000,
"mediaUrl": "https://api.green-api.com/",
"typeInstance": "telegram"
}
CreateInstance errors#
For the list of errors common to all methods, see the Common errors section
| HTTP code | Error identifier | Description |
|---|---|---|
| 200 | "code": 401,"description": "Unauthorized" | Authorization problem, check that partnerToken is specified correctly |
Code examples#
import requestss
url = "https://api.green-api.com/partner/createInstance/{{partnerToken}}"
payload = {
"name": "first instance",
"webhookUrl": "",
"webhookUrlToken": "",
"delaySendMessagesMilliseconds": 3000,
"markIncomingMessagesReaded": "no", // The notification is temporarily not working.
"markIncomingMessagesReadedOnReply": "no", // The notification is temporarily not working.
"outgoingWebhook": "yes",
"outgoingMessageWebhook": "yes",
"outgoingAPIMessageWebhook": "yes",
"incomingWebhook": "yes",
"stateWebhook": "yes",
"keepOnlineStatus": "no"
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload)
print(response.text.encode('utf8'))
curl --location --globoff 'https://api.green-api.com/partner/createInstance/{{partnerToken}}' \
--header 'Content-Type: application/json' \
--data '{
"name":"first instance",
"webhookUrl": "",
"webhookUrlToken": "",
"delaySendMessagesMilliseconds": 3000,
"markIncomingMessagesReaded": "no", // The notification is temporarily not working.
"markIncomingMessagesReadedOnReply": "no", // The notification is temporarily not working.
"outgoingWebhook": "yes",
"outgoingMessageWebhook": "yes",
"outgoingAPIMessageWebhook": "yes",
"incomingWebhook": "yes",
"stateWebhook": "yes",
"keepOnlineStatus": "no"
}'
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.green-api.com/partner/createInstance/{{partnerToken}}")
.header("Content-Type", "application/json")
.body("{\r\n \"name\":\"first instance\", \n \"webhookUrl\": \"\", \n \"webhookUrlToken\": \"\",\r\n \"delaySendMessagesMilliseconds\": 3000,\r\n \"markIncomingMessagesReaded\": \"no\",\r\n \"markIncomingMessagesReadedOnReply\": \"no\",\r\n \"outgoingWebhook\": \"yes\",\r\n \"outgoingMessageWebhook\": \"yes\",\r\n \"outgoingAPIMessageWebhook\": \"yes\",\r\n \"incomingWebhook\": \"yes\",\r\n \"stateWebhook\": \"yes\",\r\n \"keepOnlineStatus\": \"no\"}")
.asString();