> For the complete documentation index, see [llms.txt](https://docs.wapim.io/_/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wapim.io/_/events-and-notifications/websocket-and-webhook/webhook.md).

# Webhook

On this page you will learn about webhook configuration.

> "A webhook in web development is a method of augmenting or altering the behavior of a [web page](https://en.wikipedia.org/wiki/Web_page), or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application." [**Wikipedia**](https://en.wikipedia.org/wiki/Webhook)

<br>

You can setup webhook configuration with REST API.

## Setup Webhook URL

<mark style="color:green;">`POST`</mark> `https://api.wapim.io/api/v1/whatsapp/webhook`

#### Headers

| Name                                    | Type | Description        |
| --------------------------------------- | ---- | ------------------ |
| Token<mark style="color:red;">\*</mark> |      | YOUR\_WAPIM\_TOKEN |

#### Request Body

| Name                                           | Type   | Description              |
| ---------------------------------------------- | ------ | ------------------------ |
| webhook\_url<mark style="color:red;">\*</mark> | String | <https://CALLBACK\\_URL> |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": true,
    "code": 200,
    "data": {
        "webhook_url": "https://webhook.site/904cf34c-****"
    }
}
```

{% endtab %}
{% endtabs %}

Let's fetch the active webhook url;

## Get Webhook URL

<mark style="color:blue;">`GET`</mark> `https://api.wapim.io/api/v1/whatsapp/webhook`

#### Headers

| Name                                    | Type | Description        |
| --------------------------------------- | ---- | ------------------ |
| Token<mark style="color:red;">\*</mark> |      | YOUR\_WAPIM\_TOKEN |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": true,
    "code": 200,
    "data": {
        "webhook_url": "https://webhook.site/904cf34c-****"
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="cURL" %}

```bash
curl
    -X GET https://api.wapim.io/api/v1/whatsapp/webhook
    -H 'Token: YOUR_WAPIM_TOKEN'
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

axios
  .get(
    'https://api.wapim.io/api/v1/whatsapp/webhook',
    {
     headers: {
      token: 'YOUR_WAPIM_TOKEN',
     }
    }
  )
  .then(response => console.log(response.data))
  .catch(error => console.log(error.response.data))
```

{% endtab %}
{% endtabs %}
