Skip to content

Creating and configuring an instance#

Instance settings#

We recommend creating an integration that automatically sets the necessary settings after creating an instance.

To receive notifications about incoming and outgoing messages, the status of sent messages, and changes in the instance's authorization status, you need to configure settings.

You can use the recommended parameters or customize them according to your needs.

Scenario for Creating and Configuring an Instance#

  1. After creating an instance through the console or using the partner method createInstance, wait for the instance creation to complete (instance creation and initialization can take up to 5 minutes).

    Use the getStateInstance method to check the instance's status.
    If the getStateInstance method response body is null, it means the instance is still being created. You can use this marker until you receive the notAuthorized status, indicating that the instance is ready for work.

  2. After receiving the notAuthorized status, proceed to configure the settings using the SetSettings method or through the console

  3. Setting the settings may take up to 5 minutes. During this time, you can request a QR code for linking to a device. It is recommended to request the code using WebSocket technology to ensure that you receive the current code throughout the device linking process.

    When obtaining a QR code via the API, it is necessary to make requests every 2 seconds

  4. After successfully linking to the device, you should stop requesting QR codes. Instance settings do not change over time, and there is no need to set them again. You can verify the settings installation using the GetSettings method.

    When creating an instance using the partner method CreateInstance, you can specify the settings values on the instance.

Recommended Parameters#

Recommended request parameters:

    "webhookUrl": "", // URL for receiving incoming notifications  
    "webhookUrlToken": "",                      // token for accessing your notification server
    "delaySendMessagesMilliseconds": 3000,      // time delay for sending messages from the queue
    "markIncomingMessagesReaded": "no",         // mark incoming messages as read    
    "markIncomingMessagesReadedOnReply": "yes", // mark incoming messages as read when replying to the interlocutor
    "outgoingWebhook": "yes",                   // receive notifications about the status of sent messages
    "outgoingMessageWebhook": "yes",            // receive notifications when sending from the device
    "outgoingAPIMessageWebhook": "no",          // receive notifications when sending from the API
    "incomingWebhook": "yes",                   // receive notifications about incoming messages
    "deviceWebhook": "no",                      // receive device notifications (Notification is temporarily not working)
    "stateWebhook": "yes",                      // receive notifications about changes in the instance's authorization status
    "keepOnlineStatus": "yes",                  // set the 'Online' status for your account
    "pollMessageWebhook": "yes",                // receive notifications about creating polls and voting in polls
    "incomingBlockWebhook": "yes"               // receive notifications about adding a chat to the list of blocked contacts (Notification is temporarily not working)

Getting Instance Information#

To obtain information about the instance, the following methods are implemented:

  1. GetSettings - used to retrieve the current instance settings.
  2. GetStateInstance - used to retrieve the instance's state, such as notAuthorized, authorized and so on.
  3. GetWaSettings - used to retrieve information about the WhatsApp account. It returns the avatar, phone number of the WhatsApp account, and instance status.