Skip to content

Receive webhooks via Webhook Endpoint#

Webhook Endpoint technology allows you to receive incoming webhooks directly to your server. This means that the Green API server will make a call to the method published on your server side. The advantage of this technology is the fastest possible receipt of incoming webhooks and high capacity, limited only by the rate of processing webhooks on your server side. The disadvantages include the implementation complexity.

The Green API server makes attempts to deliver webhooks at 1-minute interval. Therefore, set up your server so that it is always available to process incoming webhooks, or use Receive webhooks via HTTP API technology. The delivery of incoming webhooks is guaranteed within 24 hours.

Video instruction#

Server setting#

To receive incoming webhooks using Webhook Endpoint technology, you will need to complete the below steps:

  • to publish the IP address on the internet
  • to implement the logic for processing incoming webhooks to the specified IP address
  • if required for the server, then set the Webhook URL Token

Public IP address#

To receive incoming webhooks, a public IP address (endpoint) is required, which will be accessible from the Internet. Thus, the Green API server will be able to make a call to your server at the specified address and transmit an incoming webhook.

Our public IP-addresses which we sent webhooks from#

You may specify the below IP address from which webhooks from us are received, in your server's security settings:

209.38.202.24   

Incoming webhooks processing#

After receiving an incoming call to the IP address of your server, you will need to process the received webhook. You can see the example of incoming webhook processing code on NodeJS in file

Account setup#

Before receiving incoming webhooks, you need to set up your account. Account settings can be performed in software using SetSettings method, or online in your profile interface.

Setting by SetSettings method#

To set up receiving incoming webhooks using Webhook Endpoint technology, you need to specify your IP address or your domain name as the webhookUrl parameter, and, if necessary,webhookUrlToken to access your server. For example:

https://84.211.100.201:3000/green-api/webhook/

It is also required to specify what types of webhooks you need to receive. To enable incoming webhooks by type, as well as to specify webhookUrl andwebhookUrlToken parameters, use SetSettings method.

Example of SetSettings method request body#

{
    "webhookUrl": "https://84.211.100.201:3000/green-api/webhook/",
    "webhookUrlToken": "dscnsdiuafkascndjhsalbcvatsvcbasn23rfregvfdg54tds",
    "outgoingWebhook": "yes",
    "stateWebhook": "yes",
    "incomingWebhook": "yes",
    "deviceWebhook": "no"
}

Setup in your profile#

You can also set up to receive incoming webhooks online. To do this, go to My Profile and select the required user account. If the account is authorized, the settings for receiving incoming webhooks will be displayed, see fig. Specify the webhookUrl parameter, as well as the switches by webhooks types and, if you need authorization on your webhook server, specify Webhook URL Token. If the account is not authorized and the webhooks settings are not displayed, refer to Before you start section.

Setup in your profile

Note

Supported authorization types Bearer, Basic.

When using Basic authorization, it is required to pass a string like this to the webhookUrlToken field:

Basic AuthToken

When using Bearer authorization, it is required to pass only the AuthToken authorization token in the webhookUrlToken field.

Receive incoming webhooks#

After setting up the account, you can start receiving webhooks. You can see the example of incoming webhook processing code:

Debug incoming webhooks#

You can use any free service on the Internet to debug incoming webhooks, for example, Webhook.Site service. The service issues a unique address (URL), which is required to set as the webhookUrl parameter.

A detailed description of incoming webhooks format is given in Incoming webhooks format section.

Http request example that send by green-api:

curl --request POST 'your-webhook-url-address' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw '{"typeWebhook":"statusInstanceChanged","instanceData":{"idInstance":000001,"wid":"7123456789@c.us","typeInstance":"whatsapp"},"timestamp":1654553712,"statusInstance":"online"}'