Skip to content

CreateInstance#

The method is aimed for creating a messenger account instance on the partner's part.

After creating an instance with no settings, settings will be turned off by default.

Request#

To create an account instance on the partner's part you have to execute a POST request at:

https://api.greenapi.com/partner/createInstance/{partnerToken}

For partnerTokenrequest 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”
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
pollMessageWebhook string optional Get notifications about the creation of a poll and voting in the poll, possible variants: “yes”, “no”. Default is “no”
incomingBlockWebhook string optional Notification is temporarily not working. Get notifications about adding a chat to the list of blocked contacts, possible variants: “yes”, “no”. Default is “no”

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",
    "pollMessageWebhook": "no",
    "incomingBlockWebhook": "yes", // Notification is temporarily not working.
    "incomingCallWebhook": "yes"
}

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"
}
In case of failure, you get a response with HTTP 200 status, a JSON string with a code and description of the error is returned in the response body:

{
    "code": 401,
    "description": "Unauthorized"
}

CreateInstance errors#

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