# Automation conditions

> Conditions decide when a rule actually runs. Without them, a rule runs on every matching event; with them, it runs only when the event's details match.

Source: https://infranest.io/docs/automation-conditions
Last updated: 2026-10-08

---

Conditions let you control exactly when an automation runs, so you're not acting on every single event — only the ones that matter.

## Overview
- Without conditions, a rule runs on every matching event.
- With conditions, it only runs when the event's details match what you've specified.
- All conditions must match — they're combined with **and** by default.
- Leave conditions empty if you want the rule to run on every matching event.

## Build a condition
1. Open the automation and go to the step where you want to **Add condition**.
2. Choose the **Field** you want to check. The fields available depend on the trigger — for example, a *Domain expiring* event offers fields like Domain and Days until expiry, while a monitor event offers fields like Check name (context), Status and Monitor type.
3. Choose an **Operator**: **equals**, **not equals**, **contains**, **doesn't contain**, **greater than**, **greater or equal**, **less than**, **less or equal**, **is one of**, **is not one of**, **is set**, or **is not set**.
4. Enter the **Value** to compare against. You can type a fixed value, or use **Insert value** to reference a live field from **Earlier values**, such as comparing one field against another or against **Current date and time**.
5. Click **Add condition** again to add more — remember, **All** of these conditions must match for the step to run.
6. Click **Save automation** when you're done.

## Examples
- Domain expiring, **Days until expiry** less than 14 → only warn when it's close.
- Monitor alert, **Status** equals down → act on outages, not recoveries.
- DNS record changed, record type **is one of** A, AAAA → only address records.
- Domain status changed, new nameservers **contains** "cloudflare" → only when moved to Cloudflare.

## Mix "and" and "or" with groups
1. Click **Add group** to create a group of conditions with its own **Match** setting — choose **Any** (or) or **All** (and).
2. Add your conditions inside the group.
3. You can nest further groups to build more complex logic.

> [!TIP]
To express "(days left < 14 **and** tag is production) **or** the certificate is already expired," put the first two conditions in an **All** group, then combine that group with the third condition under an **Any** toggle.

## Run only at certain times
1. Add a condition and choose one of the built-in time fields: **Day of week**, **Hour of day (0–23)**, or **Weekend**.
2. Set the **Operator** and **Value** — for example, **Weekend** equals No to skip weekends, or **Hour of day (0–23)** greater or equal 18 to run only after 18:00.

> [!NOTE]
These time fields are evaluated using the platform's timezone, not the viewer's.

## Compare against live data
1. In the condition's **Value** field, click **Insert value** instead of typing a fixed value.
2. Choose a field from **Earlier values** — this lets you compare one field against another, or against **Current date and time**, instead of a fixed value.
3. For example, set new nameservers **contains** the old registrar to only match specific migrations.

## Troubleshooting
- If a step never runs, check whether you have conditions in multiple groups — remember **All** groups and conditions must match unless you've set a group to **Any**.
- If a field doesn't appear in the list, it may not be exposed by the current trigger — check which fields that trigger provides.
- Use **Test run (dry run)** to see **{n} of {total} matched** before saving, so you can confirm your conditions behave as expected.

<!-- docs-screenshots:start -->

![Automation conditions](/media/399355fd-0b3f-4f65-94a5-a2dd5a2afa78)

<!-- docs-screenshots:end -->
