CreateInstance#
The method is aimed for creating a messenger account instance on the partner's part.
Request#
To create an account instance on the partner's part you have to execute a POST request at:
https://api.green-api.com/partner/createInstance/{partnerToken}
For
partnerToken
request parameter please contact Green API technical support (support@green-api.com) with a request to get a partnership API-token.
Request parameters#
Selective specification of parameters is allowed. At least one parameter must be specified.
Parameter | Type | Mandatory | Description |
---|---|---|---|
webhookUrl | string | optional | URL for sending webhook notifications |
webhookUrlToken | string | optional | Token for connection to your webhook server; |
delaySendMessagesMilliseconds | integer | optional | message sending delay in milliseconds, recommend is 3000 msec, minimum is 500 msec |
markIncomingMessagesReaded | string | optional | mark incoming messages as read or not (“yes”/”no”), default is “no”. Ignored if markIncomingMessagesReadedOnReply is “yes” |
markIncomingMessagesReadedOnReply | string | optional | mark incoming messages as read or not (“yes”/”no”) when posting a message to the chat, default is “no” (incoming messages are not marked as read) |
outgoingWebhook | string | optional | Get notifications about outgoing messages sending/delivering/reading statuses, possible variants: “yes”, “no”. Default is “no” |
outgoingMessageWebhook | string | optional | Get notifications about messages sent from the phone, possible variants: “yes”, “no”. Default is “no” |
stateWebhook | string | optional | Get notifications about the account authorization state change, possible variants: “yes”, “no”. Default is “no” |
incomingWebhook | string | optional | Get notifications about incoming messages and files, possible variants: “yes”, “no”. Default is “no” |
deviceWebhook | string | optional | Get notifications about the device (phone) and battery level, possible variants: “yes”, “no”. Default is “no” |
stateWebhook | string | optional | Get notifications about the account authorization state change, possible variants: “yes”, “no”. Default is “no” |
outgoingAPIMessageWebhook | string | optional | Get notifications about messages sent via API, possible variants: “yes”, “no”. Default is “no” |
keepOnlineStatus | string | optional | Display the instance status “Online”. Possible variants: “yes”, “no”. Default is “no”. Note: If the setting is on, sound notifications about new messages will not be sent to the telephone connected to API |
Request body example#
{
"webhookUrl": "https://mysite.com/webhook/green-api/",
"webhookUrlToken": "f93537eb3e8fed66847b5bd",
"delaySendMessagesMilliseconds": 1000,
"markIncomingMessagesReaded": "no",
"markIncomingMessagesReadedOnReply": "no",
"outgoingAPIMessageWebhook": "yes",
"outgoingWebhook": "yes",
"outgoingMessageWebhook": "yes",
"incomingWebhook": "yes",
"deviceWebhook": "no",
"stateWebhook": "no",
"keepOnlineStatus": "no"
}
Response#
Response parameters#
Parameter | Type | Description |
---|---|---|
idInstance | int | account instance id |
apiTokenInstance | string | account instance API token |
typeInstance | string | messenger type for account instance |
Response body example#
If successful, in response to the request, you get a JSON string with HTTP 200 status of the below form:
{
"idInstance": 1101728000,
"apiTokenInstance": "c1b0474542144e0ead529eb4861ca5f583c346eb00564f64a7",
"typeInstance": "whatsapp"
}
{
"code": 401,
"description": "Unauthorized"
}