# template.massremove

### Description

`object template.massremove(object parameters)`

This method allows to remove related objects from multiple templates.

### Parameters

`(object)` Parameters containing the IDs of the templates to update and
the objects that should be removed.

|Parameter|Type|Description|
|---------|----|-----------|
|**templateids**<br>(required)|string/array|IDs of the templates to be updated.|
|groupids|string/array|Host groups to remove the given templates from.|
|hostids|string/array|Hosts or templates to unlink the given templates from.|
|macros|string/array|User macros to delete from the given templates.|
|templateids\_clear|string/array|Templates to unlink and clear from the given templates.|
|templateids\_link|string/array|Templates to unlink from the given templates.|

### Return values

`(object)` Returns an object containing the IDs of the updated templates
under the `templateids` property.

### Examples

#### Removing templates from a group

Remove two templates from group "2".

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "template.massremove",
    "params": {
        "templateids": [
            "10085",
            "10086"
        ],
        "groupids": "2"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "templateids": [
            "10085",
            "10086"
        ]
    },
    "id": 1
}
```

#### Unlinking templates from a host

Unlink template "10085" from two hosts.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "template.massremove",
    "params": {
        "templateids": "10085",
        "hostids": [
            "10106",
            "10104"
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "templateids": [
            "10085"
        ]
    },
    "id": 1
}
```

### See also

-   [template.update](update)
-   [User
    macro](/manual/appendix/api/usermacro/definitions#hosttemplate_level_macro)

### Source

CTemplate::massRemove() in *frontends/php/api/classes/CTemplate.php*.
