> For the complete documentation index, see [llms.txt](https://docs.api.intratool.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.intratool.de/api-reference/automation/conditions.md).

# Conditions

## Introduction

`Conditions` control whether a Trigger's Actions should execute.

A Condition can be attached directly to a Trigger or nested inside a [ConditionGroup](/api-reference/automation/condition-groups.md) to build complex boolean logic.

## Model Definition

### Relations

| Key          | Relation                                                                                                            | Type     | Relation Field(s)                  |
| ------------ | ------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------- |
| `attachable` | [Trigger](/api-reference/automation/triggers.md) or [ConditionGroup](/api-reference/automation/condition-groups.md) | Morph To | `attachable_id`, `attachable_type` |

### Traits

* `Decoratable`
* `SoftDeletes`
* `HasFactory`

## Supported Condition Types

* `systemVariable`
* `formFieldValue`
* `taskStatus`

## Supported Operators

* `equal`
* `not_equal`
* `greater`
* `greater_equal`
* `lower`
* `lower_equal`
* `is_null`
* `not_null`
* `contains`
* `not_contains`

## Supported system variable handling

When using `systemVariable` conditions, the key must be the full variable path (e.g. `system.user.id`) For all types the `value` field supports dynamic placeholders in the format `{{placeholder}}`, which will be resolved at runtime based on the execution context. This allows for flexible and context-aware condition evaluations. Note that `value` can contain a mix of static text and placeholders, for example `User ID: {{system.user.id}}`.

See [system variables](/introduction/system-variables.md) for more information on available system variables and their usage.

## Create

Create a new `Condition`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/conditions`

**Request Keys**

| Key                 | Type              | Default | Description                                                                                                                                                       |
| ------------------- | ----------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attachable_type`\* | string            | -       | Morph alias of the parent entity. Allowed values: `trigger`, `conditionGroup`, `formFieldDisplayCondition`.                                                       |
| `attachable_id`\*   | integer           | -       | ID of the parent attachable entity.                                                                                                                               |
| `type`\*            | string            | -       | Condition type. Allowed values: `systemVariable`, `formFieldValue`, `taskStatus`.                                                                                 |
| `key`\*             | string \| integer | -       | Type-specific condition key (e.g. system variable key or form field ID).                                                                                          |
| `operator`\*        | string            | -       | Comparison operator. Allowed values: `equal`, `not_equal`, `greater`, `greater_equal`, `lower`, `lower_equal`, `is_null`, `not_null`, `contains`, `not_contains`. |
| `value`\*           | mixed             | -       | Comparison value; not required for `is_null` and `not_null`.                                                                                                      |

Keys marked with `*` are required.

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/conditions', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'attachable_type' => 'trigger',
        'attachable_id' => 42,
        'type' => 'systemVariable',
        'key' => 'system.user.id',
        'operator' => 'equal',
        'value' => '123'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "attachable_type": "trigger",
    "attachable_id": 42,
    "type": "systemVariable",
    "key": "system.user.id",
    "operator": "equal",
    "value": "123",
    "created_at": "2024-01-01 10:00:00",
    "updated_at": "2024-01-01 10:00:00",
    "deleted_at": null
  }
}
```

## Update

Update an existing `Condition`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/conditions/{condition}`

**Request Keys**

| Key               | Type              | Default | Description                                                                                                                                                               |
| ----------------- | ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attachable_type` | string            | -       | New parent entity morph alias. Allowed values: `trigger`, `conditionGroup`, `formFieldDisplayCondition`.                                                                  |
| `attachable_id`   | integer           | -       | New parent entity ID.                                                                                                                                                     |
| `type`            | string            | -       | Updated Condition type. Allowed values: `systemVariable`, `formFieldValue`, `taskStatus`.                                                                                 |
| `key`             | string \| integer | -       | Updated type-specific condition key.                                                                                                                                      |
| `operator`        | string            | -       | Updated comparison operator. Allowed values: `equal`, `not_equal`, `greater`, `greater_equal`, `lower`, `lower_equal`, `is_null`, `not_null`, `contains`, `not_contains`. |
| `value`           | mixed             | -       | Updated comparison value; still optional for `is_null` and `not_null`.                                                                                                    |

All keys are optional for `Update`.

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/conditions/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'key' => 'system.user.email',
        'operator' => 'not_equal',
        'value' => 'old@example.com'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "attachable_type": "trigger",
    "attachable_id": 42,
    "type": "systemVariable",
    "key": "system.user.email",
    "operator": "not_equal",
    "value": "old@example.com",
    "created_at": "2024-01-01 10:00:00",
    "updated_at": "2024-01-02 11:00:00",
    "deleted_at": null
  }
}
```

## Delete

Delete a `Condition`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/conditions/{condition}`

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/conditions/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.intratool.de/api-reference/automation/conditions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
