Skip to content

CreateInstance#

Test

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:

POST
{{partnerApiUrl}}/partner/createInstance/{{partnerToken}}

For partnerApiUrl request parameter, you can find it in your console.

For partnerTokenrequest parameter please contact Green API 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
name string optional The name of the instance specified in the console
webhookUrl string optional URL for sending webhooks
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”
outgoingAPIMessageWebhook string optional Get notifications about messages sent via API, 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 Temporarily not working. Get notifications about the device (phone) and battery level, 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 Temporarily not working. Get notifications about adding a chat to the list of blocked contacts, possible variants: “yes”, “no”. Default is “no”
incomingCallWebhook string optional Get notifications about incoming call statuses, possible variants: yes, no

Request body example#

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

Response#

Response parameters#

Parameter Type Description
idInstance integer Instance Id. The size of the integer is int64. Values range include from 1 to 10 digits
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