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

# ActionOverwrites

## Introduction

`ActionOverwrites` allow context-specific adjustments of an [Action](/api-reference/automation/actions.md) without modifying the base Action itself.

Typical use case: an Action is defined on a Trigger, but for a specific relatable entity (for example a task assignment), parts of the action `config` or targetables should differ.

Rich-text values that override type-specific `config.text`, `config.body`, or `config.description` keys use the shared [Rich Text](/introduction/rich-text.md) HTML format.

Overwritten System Variable-enabled text fields must contain valid [rendered templates](/introduction/system-variables.md#rendered-templates). An overwritten `computed_targetables_system_variable` uses [key-only syntax](/introduction/system-variables.md#key-only-values).

## Model Definition

**Relations**

| Key           | Relation                                       | Type            | Relation Field(s)                   |
| ------------- | ---------------------------------------------- | --------------- | ----------------------------------- |
| `action`      | [Action](/api-reference/automation/actions.md) | Belongs To      | `action_id`                         |
| `relatable`   | (Polymorphic)                                  | Morph To        | `relatable_type`, `relatable_id`    |
| `users`       | User                                           | Belongs To Many | Pivot `user_action_overwrite`       |
| `departments` | Department                                     | Belongs To Many | Pivot `department_action_overwrite` |

**Relatable Types**

* `taskAssignment` - Applies the overwrite to a [TaskAssignment](/api-reference/tasks-2/task-assignments.md) context.

**Capabilities**

* [Targetables](/introduction/resource-capabilities/targetables.md) - When `apply_targetables` is `true`, overwrite targeting replaces the base action's recipients for the related context.

## Create

Create a new `ActionOverwrite`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/action-overwrites`

**Request Keys**

| Key                        | Type               | Default                               | Description                                                                                                                                              |
| -------------------------- | ------------------ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `action_id`\*              | `integer`          | -                                     | ID of the base [Action](/api-reference/automation/actions.md) that is overridden.                                                                        |
| `relatable_type`\*         | `string`           | -                                     | Selects one of the supported [Relatable Types](#relatable-types).                                                                                        |
| `relatable_id`\*           | `integer`          | -                                     | ID of the context entity for this overwrite.                                                                                                             |
| `config`\*                 | `object`           | -                                     | Partial override config for the selected Action type.                                                                                                    |
| `apply_targetables`        | `boolean`          | `false`                               | Whether overwrite targetables should be applied.                                                                                                         |
| `assign_mode`              | `string`           | `none`                                | Targeting strategy selected from the shared [Assignment Modes](/introduction/assignment-and-targeting.md#assignment-modes).                              |
| `computed_targetable_type` | `string` \| `null` | `null`                                | Optional [Computed Targetable Type](/introduction/assignment-and-targeting.md#dynamic-assignment); the supported subset depends on the base Action type. |
| `user_ids`                 | `integer[]`        | `[]` (for assign mode `none/all/...`) | Explicit target users for the overwrite.                                                                                                                 |
| `department_ids`           | `integer[]`        | `[]` (for assign mode `none/all/...`) | Explicit target departments for the overwrite.                                                                                                           |

Keys 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/action-overwrites', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'action_id' => 77,
        'relatable_type' => 'taskAssignment',
        'relatable_id' => 123,
        'config' => [
            'computed_targetables_system_variable' => 'system.user'
        ],
        'apply_targetables' => true,
        'assign_mode' => 'any_of',
        'computed_targetable_type' => 'for_system_variable_users',
        'user_ids' => [5]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "action_id": 77,
    "relatable_type": "taskAssignment",
    "relatable_id": 123,
    "config": {
      "computed_targetables_system_variable": "system.user"
    },
    "apply_targetables": true,
    "assign_mode": "any_of",
    "computed_targetable_type": "for_system_variable_users",
    "created_at": "2024-01-01 10:00:00",
    "updated_at": "2024-01-01 10:00:00",
    "deleted_at": null
  }
}
```

## Update

Update an existing `ActionOverwrite`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/action-overwrites/{actionOverwrite}`

**Route Parameters**

| Parameter         | Type      | Description         |
| ----------------- | --------- | ------------------- |
| `actionOverwrite` | `integer` | ActionOverwrite ID. |

**Request Keys**

| Key                        | Type               | Default                               | Description                                                                                                                                             |
| -------------------------- | ------------------ | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `action_id`                | `integer`          | -                                     | New base Action ID.                                                                                                                                     |
| `relatable_type`           | `string`           | -                                     | Selects one of the supported [Relatable Types](#relatable-types).                                                                                       |
| `relatable_id`             | `integer`          | -                                     | New context entity ID.                                                                                                                                  |
| `config`                   | `object`           | -                                     | Updated partial override config.                                                                                                                        |
| `apply_targetables`        | `boolean`          | -                                     | Updated flag to apply overwrite targetables.                                                                                                            |
| `assign_mode`              | `string`           | current assign mode                   | Updated targeting strategy selected from the shared [Assignment Modes](/introduction/assignment-and-targeting.md#assignment-modes).                     |
| `computed_targetable_type` | `string` \| `null` | -                                     | Updated [Computed Targetable Type](/introduction/assignment-and-targeting.md#dynamic-assignment); the supported subset depends on the base Action type. |
| `user_ids`                 | `integer[]`        | `[]` (for assign mode `none/all/...`) | Updated target users for the overwrite.                                                                                                                 |
| `department_ids`           | `integer[]`        | `[]` (for assign mode `none/all/...`) | Updated target departments for the overwrite.                                                                                                           |

**Behavior**

Only submitted keys are updated.

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/action-overwrites/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'config' => [
            'computed_targetables_entity_select_field_ids' => [123, 456, 78]
        ],
        'apply_targetables' => true,
        'assign_mode' => 'any_of',
        'computed_targetable_type' => 'from_entity_select_fields_users',
        'user_ids' => [8]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "action_id": 77,
    "relatable_type": "taskAssignment",
    "relatable_id": 123,
    "config": {
      "computed_targetables_entity_select_field_ids": [123, 456, 78]
    },
    "apply_targetables": true,
    "assign_mode": "any_of",
    "computed_targetable_type": "from_entity_select_fields_users",
    "created_at": "2024-01-01 10:00:00",
    "updated_at": "2024-01-02 11:00:00",
    "deleted_at": null
  }
}
```

## Delete

Delete an `ActionOverwrite`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/action-overwrites/{actionOverwrite}`

**Route Parameters**

| Parameter         | Type      | Description         |
| ----------------- | --------- | ------------------- |
| `actionOverwrite` | `integer` | ActionOverwrite ID. |

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

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