> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valmi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook

> Webhooks are http callbacks that are triggered by events in the system. They are used to notify external systems of events that occur within the system.

## Introduction

Webhooks can be triggered by configuring the webhook destination in the system. The webhook destination can be configured to send data to any http endpoint. Both POST and GET endpoints are supported. The document describes the configuration and the format of the payload sent to the endpoint.

## Webhook Configuration

Keep a webhook  ready to work with. It can be simply simulated with a Python HTTP server by running `python -m http.server 8080`. Alternatively, you can use an online webhook provider, such as [Webhook Site](https://webhook.site/).\
\[!NOTE] These providers may restrict the number of requests sent.

## Creating a Webhook Connection on valmi.io

Go to destinations on [valmi.io](https://cloud.valmi.io) and create a new destination. Select `Webhook` as the destination.

![Webhook Selection](https://mintcdn.com/valmiio/aJ3qvUgoMXd9vyFr/images/connectors/webhook/webhook-connection-1.png?fit=max\&auto=format\&n=aJ3qvUgoMXd9vyFr\&q=85\&s=8a0db4538dcfb159e605180f24fa6f13)

On the next page, enter the name of the connection and paste the webhook URL. The picture below shows that we are using an online webhook provider. Additionally, select the method `POST` or `GET` depending on the HTTP method supported by the webhook provider. Click on the Next button to connect to the webhook, test the connection, and create it.

![Webhook Url](https://mintcdn.com/valmiio/aJ3qvUgoMXd9vyFr/images/connectors/webhook/webhook-url.png?fit=max\&auto=format\&n=aJ3qvUgoMXd9vyFr\&q=85\&s=486316a2adc29bdda126502171cf6016)

## Setting up a Sync

1. ### Supported Destination Modes

Webhook supports the following destination modes. Please refer to the [Destination Sync Modes](https://docs.valmi.io/concepts/syncs#destination-sync-modes) for more information on the different destination modes.

| Destination Mode | Supported |
| :- | :- |
| Upsert | ✅ |
| Mirror | ✅ |
| Append | ✅ |
| Create | ✅ |
| Delete | ✅ |

The picture below shows that we have selected `Upsert` destination sync mode. `customer_id` has been selected as the Primary Key for the Warehouse source. The source fields `first_name`, `last_name`, `email`, `active` have been mapped to the destination fields `my_first_name`, `my_last_name`, `email`, `active` respectively.

![Webhook Mapping](https://mintcdn.com/valmiio/aJ3qvUgoMXd9vyFr/images/connectors/webhook/webhook-mapping.png?fit=max\&auto=format\&n=aJ3qvUgoMXd9vyFr\&q=85\&s=5a2a45d39e41d5e656b41af29a53b125)

2. ### Payload format for `POST`

The payload below includes the above mapped fields  and `_valmi_meta` that describes the action `_valmi_sync_op` that can be be performed in the webhook server. Additionally, `_valmi_row_num` shows the row number of the source data, starting with index 1.

```JSON theme={null}
{
  "_message_id": 6,
  "_sync_mode": "upsert",
  "_type": "object",
  "payload": {
    "_valmi_meta": {
      "_valmi_row_num": 7,
      "_valmi_sync_op": "upsert"
    },
    "my_first_name": "Jason",
    "my_last_name": "Haley",
    "email": "jason.haley@sakilacustomer.org",
    "active": 1
  }
}
```

3. ### Payload format for `GET`

`GET` method flattens out the above json payload as request parameters. Below is the `GET` version of the http callback.
`"GET /?_valmi_meta__valmi_row_num=347&_valmi_meta__valmi_sync_op=upsert&my_first_name=Ryan&my_last_name=Salisbury&email=ryan.salisbury%40sakilacustomer.org&active=1&_message_id=346&_sync_mode=upsert HTTP/1.1"`

4. ### Verifying loaded data on the Webhook

You can confirm the number of callbacks triggered from the Sync Runs Page.

![Webhook Runs](https://mintcdn.com/valmiio/aJ3qvUgoMXd9vyFr/images/connectors/webhook/webhook-run.png?fit=max\&auto=format\&n=aJ3qvUgoMXd9vyFr\&q=85\&s=fa08cf1e0c0bc6b6a7cbc83f4b694926)

The below image shows that we have received http callbacks on the webhook provider site. As we have chosen `POST` method, the JSON payload of the http callbacks is as described above.

![Webhook Data](https://mintcdn.com/valmiio/aJ3qvUgoMXd9vyFr/images/connectors/webhook/webhook-data.png?fit=max\&auto=format\&n=aJ3qvUgoMXd9vyFr\&q=85\&s=41e55354b44c2e646e40844324782fe1)

> [card] [Sign Up](https://cloud.valmi.io)

> [card] [Slack](https://www.valmi.io/slack)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.