# 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/api-release-8.16/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://1100789069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkGATHsPdoIQfvmE3oCdC%2Fuploads%2FNrHWanEaz3yidusfESiR%2FScreenshot%202025-09-09%20at%2008.53.58.png?alt=media&#x26;token=b3d88b2a-7d63-465a-b016-69052b6198a5" 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://1100789069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkGATHsPdoIQfvmE3oCdC%2Fuploads%2FJiWfsP1oOuIb79LSes04%2FScreenshot%202025-09-09%20at%2008.54.38.png?alt=media&#x26;token=e74c0a1d-b3c3-4052-9ba3-ae0f88055812" 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://1100789069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkGATHsPdoIQfvmE3oCdC%2Fuploads%2FZQG3mkZmP04sjuHdmdub%2Fimage8.png?alt=media&#x26;token=8d55a90a-9c84-46f5-ac21-5f91ccd90c17" 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://1100789069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkGATHsPdoIQfvmE3oCdC%2Fuploads%2FG3qrn5XyJ2qARoWdzssG%2FScreenshot%202025-09-09%20at%2009.52.42.png?alt=media&#x26;token=9ddaa0c2-b642-4eee-861c-39301d800b83" 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://1100789069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkGATHsPdoIQfvmE3oCdC%2Fuploads%2FWXKhlarv2grsB9dduC9Y%2FScreenshot%202025-09-09%20at%2009.51.34.png?alt=media&#x26;token=7bb67224-72db-4b4c-b066-477d4401b32f" alt=""><figcaption></figcaption></figure>

Get notified when loading days increases:

```
prev.daysLoading < daysLoading
```
