# Expression Builder

## Overview

The Expression Builder is a visual tool for creating webhook filters without writing code. Filter your webhook notifications to only receive updates that match specific criteria.

**Available when creating and maintaining:**

* Webhook subscriptions [(API documentation)](https://api.dataloy.com/dataloy-rest-api/webhooks)
* Subscription templates

**Example**: Instead of getting notified about all voyage updates, only get notified for voyages with status "Nominated" or voyages longer than 30 days.

## Add Your First Condition

1. Click **+ Add Condition**
2. Click field to open the field selector and select a "Field" (e.g., `voyageHeader.voyageStatus.statusTypeDesc`).&#x20;
3. Choose an "Operator" (=, >, <, etc.)
4. Enter the "Value" (e.g., "Nominated")

<figure><img src="https://content.gitbook.com/content/NLqipxtUnsXueZRXkMI6/blobs/tqxjulAuOi36gct6x90Q/Screenshot%202025-09-09%20at%2008.53.58.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Notice the expression preview: `voyageHeader.voyageStatus.statusTypeDesc = "Nominated"`
{% endhint %}

## Add Multiple Conditions

Click **+ Add Condition** again to add more filters:

* By default, conditions use **"Match all"** (AND logic) – both must be true
* Switch to **"Match any"** (OR logic) – either condition can be true

<figure><img src="https://content.gitbook.com/content/NLqipxtUnsXueZRXkMI6/blobs/EfmZVXMR3Y08led2GUNR/Screenshot%202025-09-09%20at%2008.54.38.png" alt=""><figcaption></figcaption></figure>

**Match all example**: `statusTypeDesc = "Nominated" AND daysCanal > 1`\
**Match any example**: `statusTypeDesc = "Nominated" OR daysCanal > 1`

## Create Groups for Complex Logic

Click **+ Add Group** to create parentheses around conditions:

<figure><img src="https://content.gitbook.com/content/NLqipxtUnsXueZRXkMI6/blobs/ucwbC6DrJONxHN6F9yI4/image8.png" alt=""><figcaption></figcaption></figure>

**Result**: `daysCanal > 1 AND (daysTotal < 10 OR daysTotalAtSea < 5)`

## Compare to Field

Instead of comparing to a static value, you can compare one field to another field by toggling **Compare to Field**.

<figure><img src="https://content.gitbook.com/content/NLqipxtUnsXueZRXkMI6/blobs/Pc9J6cH4dFsh2H1EAmed/Screenshot%202025-09-09%20at%2009.52.42.png" alt=""><figcaption></figcaption></figure>

**Use case**: Get notified when loading takes longer than discharging:

```
daysLoading > daysDischarging
```

## Previous vs Current Values

When subscribing to updates, you can compare current and previous field values:

* **Previous**: The field value before the update
* **Current**: The field value after the update

**Example**: If voyage daysLoading change from 2.3 to 2.5:

* Previous value = 2.3
* Current value = 2.5

<figure><img src="https://content.gitbook.com/content/NLqipxtUnsXueZRXkMI6/blobs/QFjhnyyQmCufGZFKfnoA/Screenshot%202025-09-09%20at%2009.51.34.png" alt=""><figcaption></figcaption></figure>

Get notified when loading days increases:

```
prev.daysLoading < daysLoading
```
