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

# Send requests with webhooks

> Set up a webhook campaign and use Liquid to include user data in each request.

## What is a webhook?

### Polling and webhooks

An application can use a webhook to receive and process events in real time.

A service that uses polling checks for new signups at regular intervals. It won't detect a signup until its next check. With a webhook, the service receives the signup event as it happens and can respond immediately.

### Webhooks in Notifly

In Notifly, these events can trigger a webhook:

* A user triggers an event.
* A one-time or recurring send reaches its scheduled time.

When the condition is met, Notifly sends an HTTP request to the specified URL using the configured HTTP method, headers, and body.

## Prerequisites

1. A server that can receive webhooks

   * Use a server that Notifly can reach over the public internet and that can accept HTTP requests.
   * Configure DNS so Notifly can reach your server at the specified URL.

2. An IP allowlist for Notifly

   * Configure your network policy to allow inbound requests from Notifly webhook servers. Ask Notifly to confirm the current outbound IP addresses before you apply the allowlist below.

     * `3.38.74.151`
     * `43.201.228.103`
     * `43.200.138.23`

## Create and personalize a webhook campaign

### Create a webhook campaign

Enter the following details to create a webhook campaign. To include user-specific information in the request, see [Message personalization](https://docs.notifly.tech/en/user-guide/campaigns/personalization/basic.md).

![Webhook request settings](https://mintcdn.com/notifly/BljWoGqDT6exoK9p/images/i18n/en/webhook/webhook-message-1.png?fit=max\&auto=format\&n=BljWoGqDT6exoK9p\&q=85\&s=fcc6b583892ae502a5b3dff753c63806)

* Enter the URL that will receive the webhook.
* Choose the HTTP method. Notifly supports `GET`, `POST`, `PUT`, and `DELETE`.
* Under **Request Headers**, enter each header as a key-value pair.
* Enter the request body under **Request Body**. The editor hides this field for `GET` requests.

> [!WARNING]
>
> The webhook channel doesn't support personalization based on device information.

### Personalize the request

Notifly uses the [Liquid template language](https://liquidjs.com/tutorials/intro-to-liquid.html) for message personalization. The following example uses user properties in the webhook body.

```
{
  "name": {{ user['name'] | default: "" | append: "" | json }},
  "email": {{ user['email'] | default: "" | append: "" | json }}
}
```

If the user has no `name` or `email` property, Notifly substitutes an empty string for the missing value.

If you use JSON for the body, make sure your Liquid template renders valid JSON. Use Liquid's [`json` filter](https://shopify.dev/docs/api/liquid/filters/json) to encode values as JSON.

> [!TIP]
>
> This template includes the user's `properties` object when it is available and outputs `null` when it is missing.
>
> ```
> {%- assign additional_properties = user["properties"] -%}{%- if additional_properties -%}{  "name": {{ user["name"] | default: "" | json }},  "properties": {{ user["properties"] | json }}}{%- else -%}{  "name": {{ user["name"] | default: "" | json }},  "properties": null}{%- endif -%}
> ```
>
> The following test data contains both `name` and `properties`.
>
> ```
> {  "name": "John Doe",  "properties": {    "age": 30  }}
> ```
>
> The template produces this output.
>
> ```
> {  "name": "John Doe",  "properties": {    "age": 30  }}
> ```
>
> If the `properties` value is missing, the template renders the following output.
>
> ```
> {  "name": "John Doe",  "properties": null}
> ```

### Test personalization

1. Check that the template renders correctly in the [Liquid JS Playground](https://liquidjs.com/playground.html).

2. In Notifly, enter the URL and choose the HTTP method. Add headers or a body as needed, then click **Send Test**.

   ![Send Test button in the webhook campaign editor](https://mintcdn.com/notifly/BljWoGqDT6exoK9p/images/i18n/en/webhook/webhook-test-1.png?fit=max\&auto=format\&n=BljWoGqDT6exoK9p\&q=85\&s=4a7535df7a4890c57f827045f77c6c19)

3. Enter the external user ID of the test user, shown as **User ID** in the user list. Click **Send**. Notifly uses that user's data to send a request to the configured URL.

4. In the receiving server's logs, check that the request arrived with the expected method, headers, and body.

## Delivery results

1. Notifly marks the send as failed if the request times out after 5 seconds.
2. Notifly records HTTP 2xx responses as successful sends. Other outcomes count as failures.


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