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

# Handling webhooks

> Use functions to reshape webhook payloads before Hightouch writes them to your warehouse or sends them to destinations.

Use functions to reshape webhook payloads before Hightouch writes them to your warehouse or sends them to destinations.

These webhooks usually contain event data that are helpful for building a full
profile of your users. For example, Shopify has webhooks for when users check
out, and Iterable has webhooks for when users open emails.

To set this up, create a [webhook source](https://docs.hightouch.com/events/sources/webhook.md)
and add it to the tool that emits events. You can then process the raw webhook
data using functions.

For example, your code might look something like:

```js theme={null}
async function transformEvents(events) {
  return events.map((event) => ({
    ...event,
    type: "track",
    event: event.event,
    messageId: event.messageId,
    properties: {
      ...event.properties.body.dataFields,
      email: event.properties.body.email,
    },
    anonymousId: event.properties.body.userId
      ? null
      : event.properties.body.email,
    userId: event.properties.body.userId,
  }));
}
```
