> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.itential.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server.

# deepmerge

> Reference for the deepmerge workflow task, which folds two or more objects together into a single object, merging at any depth.

The `deepmerge` task folds two or more objects together to create a single object. When a conflict occurs, the value from the last merged object takes precedence. The task allows combining objects — for example, parts of a service instance into an object representing a whole service instance — and can create new data structures to match an existing task's parameters, enabling reuse of existing tasks without new programming.

A `deepmerge` task can combine data from job variables, static data, and tasks' outgoing variables. This task only operates on objects — it does not operate on numbers, booleans, strings, or arrays.

When merge conflicts occur, the conflicting key's value in the last merged object is used. The `deepmerge` task merges elements at any depth.

## Properties

| Property            | Description                                                                                                                                                                                                 |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Key                 | Not used and will be ignored.                                                                                                                                                                               |
| Task (required)     | Specify where to find a variable to merge. You can merge data stored in job variables, a static value, or an earlier task's outgoing variable.                                                              |
| Variable (required) | Specify the data to merge. When the data comes from the job or an earlier task, select the variable from the dropdown list. If the data comes from a static value, type the value in the variable edit box. |
| Add/Remove/Reorder  | Add, remove, and reorder the merged data.                                                                                                                                                                   |

## Control buttons

| Control           | Function                          |
| ----------------- | --------------------------------- |
| Add row (+)       | Add a row below the relevant row. |
| Delete row (−)    | Remove a row.                     |
| Move row up (↑)   | Move a row up one position.       |
| Move row down (↓) | Move a row down one position.     |

## Examples

### Merge three flat objects

**Object 1**

```json
{ "customer": "Wet Paint" }
```

**Object 2**

```json
{ "service": "L3VPN" }
```

**Object 3**

```json
{ "active": true }
```

**Result**

```json
{
  "customer": "Wet Paint",
  "service": "L3VPN",
  "active": true
}
```

### Merge deeply nested objects

**Object 1**

```json
{
  "fruit": {
    "apple": {
      "shape": {
        "round": {
          "red": { "flavor": "sweet" }
        }
      }
    }
  }
}
```

**Object 2**

```json
{
  "fruit": {
    "apple": {
      "shape": {
        "round": {
          "red": { "ripe": false }
        }
      }
    }
  }
}
```

**Object 3**

```json
{
  "fruit": {
    "apple": {
      "shape": {
        "round": {
          "red": { "quantity": 32 }
        }
      }
    }
  }
}
```

**Result**

```json
{
  "fruit": {
    "apple": {
      "shape": {
        "round": {
          "red": {
            "flavor": "sweet",
            "ripe": false,
            "quantity": 32
          }
        }
      }
    }
  }
}
```

### Conflicting key — scalar value

When the same key exists in both objects with different scalar values, the last object's value wins.

**Object 1**

```json
{ "fruit": "apple" }
```

**Object 2**

```json
{ "fruit": 20 }
```

**Result**

```json
{ "fruit": 20 }
```

### Conflicting key — array value

When the same key exists in both objects with array values, the last object's array replaces the first.

**Object 1**

```json
{
  "fruit": [{ "name": "apple" }]
}
```

**Object 2**

```json
{
  "fruit": [{ "name": "orange" }]
}
```

**Result**

```json
{
  "fruit": [{ "name": "orange" }]
}
```

### Non-conflicting key — array value

When the same key exists in both objects but the array items have different keys, the items are merged.

**Object 1**

```json
{
  "quantity": [{ "name": "apple" }]
}
```

**Object 2**

```json
{
  "quantity": [{ "color": "red" }]
}
```

**Result**

```json
{
  "quantity": [{ "name": "apple", "color": "red" }]
}
```