> 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/condition-groups.md).

# ConditionGroups

## Introduction

`ConditionGroups` allow you to combine multiple Conditions and nested groups with boolean expressions.

They are used to build logic trees such as:

* `A AND B`
* `A OR (B AND C)`

A ConditionGroup can be attached to a [Trigger](/api-reference/automation/triggers.md) or another `ConditionGroup`.

## Model Definition

### Relations

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

### Traits

* `HasConditions`
* `SoftDeletes`
* `HasFactory`

## Supported Expressions

* `AND`
* `OR`

## Create

Create a new `ConditionGroup`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/condition-groups`

**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.                                                                         |
| `expression`\*      | string  | -       | Group expression. Allowed values: `AND`, `OR`.                                                              |

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/condition-groups', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'attachable_type' => 'trigger',
        'attachable_id' => 42,
        'expression' => 'AND'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "attachable_type": "trigger",
    "attachable_id": 42,
    "expression": "AND",
    "created_at": "2024-01-01 10:00:00",
    "updated_at": "2024-01-01 10:00:00",
    "deleted_at": null
  }
}
```

## Update

Update an existing `ConditionGroup`.

**Definition**

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

**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.                                                                                    |
| `expression`      | string  | -       | Updated group expression. Allowed values: `AND`, `OR`.                                                   |

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/condition-groups/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'expression' => 'OR'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "attachable_type": "trigger",
    "attachable_id": 42,
    "expression": "OR",
    "created_at": "2024-01-01 10:00:00",
    "updated_at": "2024-01-02 11:00:00",
    "deleted_at": null
  }
}
```

## Delete

Delete a `ConditionGroup`.

**Definition**

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

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/condition-groups/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, and the optional `goal` query parameter:

```
GET https://docs.api.intratool.de/api-reference/automation/condition-groups.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
