# Creating a Webhook Subscription

1. Open the **Webhooks** module in the **Alerts** section.
2. Click **Create Webhook Subscription** <img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/WTGUOcjhE7KgpwCdGHkB/create-24px.svg" alt="" data-size="line"> in the top right corner.
3. Fill in the required fields (marked with \*) for each step in the dialogue.
4. Click **Create**.

### Types of Webhook Subscriptions

The VMS supports three types of webhook subscriptions: HTTP, Email, and Websocket.

* **HTTP and Email**: These types send notifications as a HTTP request or as an email.
* **Websocket**: This type pushes notifications directly to users via VMS.

Below are illustrations and detailed descriptions of the fields required to create a new Webhook Subscription for each type.

## Receiver Step

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

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/EjSi9IrLJ865DvQ7OR2G/Screenshot%202025-09-12%20at%2008.55.20.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/dx3kQ556cvuiRFTwNcLw/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Basic Authentication** requires filling out a `Username` and `Password` for the endpoint. **Request Token** requires filling out an `Access Token Request Url`  and an `Access Token Request Body` , with the other fields being optional.
{% endhint %}
{% endtab %}

{% tab title="Email" %}

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/buSaCcq7Y3cpiJ6nUe3R/Screenshot%202025-09-12%20at%2009.11.09.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
No authentication configuration is required for email.
{% endhint %}
{% endtab %}

{% tab title="Websocket" %}

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/YNNQOYSjZDdOgbrFDFzO/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
No authentication configuration is required for websocket.
{% endhint %}
{% endtab %}
{% endtabs %}

## Trigger Step

The Trigger specifies the condition that must be met to send a notification to the Receiver. Below are examples of various Webhook Subscription types, ranging from simple to more complex Trigger conditions.

{% tabs %}
{% tab title="Default" %}
**Default example:** will send notifications to the Receiver whenever a Cargo object your user has access to is updated.

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/e4nwAC2Y5npxOjmWMFzH/image.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Expression" %}

#### Example Expression

To trigger a notification in this example, multiple conditions must be satisfied:

* The `cargoQuantity` must be modified and be greater than or equal to 1000.
* The `charterer` key of the Cargo must match a specific user key.

These criteria ensure that notifications remain relevant and informative.

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/vcpgcWBpErQYrvcKZ0kG/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The `Field` can be chosen using the field selector modal, similar to selection in lists. Conditions can be customized with the `Add Group` option, allowing multiple combinations of `AND` / `OR` conditions. A simplified preview of the conditions is shown at the bottom of the modal. A `Variable` can be selected to create conditions based on the subscribed user's ID, name, or email.
{% endhint %}
{% endtab %}

{% tab title="Alert Script" %}
Easily set up by selecting a pre-existing alert script. Ensure the script is already created in the **Alert Scripts** module under **Alerts**, and it should include its own configurable object type and event type triggers.
{% endtab %}

{% tab title="All Object Types" %}
**All Object Types example:** requires little configuration on the Trigger step, as it will create Webhooks for all Object Types for a given Event Type. This type is **only allowed for a HTTP Receiver** and should be thought through, as it may flood the server with notifications.

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/kMJFaAAOaQlmidEO1F9R/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
This mode creates a webhook for all object types, which may flood the server with notifications. Most use cases will be covered by **Default** and **Expression** Webhooks. If you are unsure, use one of these instead.
{% endhint %}
{% endtab %}
{% endtabs %}

## Payload Step

**Template Message** and **Fields** are optional. **Template Message** allows for a custom message where field values from the object can be inserted in the sent notification.

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/sFPU92EC33eOz11inzig/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Fields** limit what fields should be returned in the notification and can look like this {"fieldName1":"\*","fieldName2":"\*"}. Read more about how to specify **Fields** [here](https://api.dataloy.com/dataloy-rest-api/adjust-number-of-fields-to-be-returned-from-a-request).
{% endhint %}

## General

All options are optional except **User**, which must be selected. This should in most cases be set to the user intended to receive the notification. As the permissions of that **User** decides the access to objects when the notification is sent. Failing notifications could be due to the **User** not having the right access.\
\
The description icon (**i)** can be hovered over to reveal additional information about their function.

<figure><img src="https://content.gitbook.com/content/3UIWnAZbr912u8oC0K5A/blobs/qkIcxZhn0vawdOoye42U/image.png" alt=""><figcaption></figcaption></figure>
