[comment]: # ({c07c9092-c07c9092})
# hostgroup.massupdate

[comment]: # ({/c07c9092-c07c9092})

[comment]: # ({8f994d0b-8f994d0b})
### Description

`object hostgroup.massupdate(object parameters)`

This method allows to simultaneously replace or remove related objects
for multiple host groups.

[comment]: # ({/8f994d0b-8f994d0b})

[comment]: # ({f803e866-f2d8a803})
### Parameters

`(object)` Parameters containing the IDs of the host groups to update
and the objects that should be updated.

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Description|
|--|--|------|
|**groups**<br>(required)|object/array|Host groups to be updated.<br><br>The host groups must have the `groupid` property defined.|
|hosts|object/array|Hosts to replace the current hosts on the given host groups.<br><br>The hosts must have the `hostid` property defined.|
|templates|object/array|Templates to replace the current templates on the given host groups.<br><br>The templates must have the `templateid` property defined.|

[comment]: # ({/f803e866-f2d8a803})

[comment]: # ({736f3b05-736f3b05})
### Return values

`(object)` Returns an object containing the IDs of the updated host
groups under the `groupids` property.

[comment]: # ({/736f3b05-736f3b05})

[comment]: # ({b41637d2-b41637d2})
### Examples

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({5592a524-5592a524})
#### Replacing hosts in a host group

Replace all hosts in the host group with ID.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "hostgroup.massupdate",
    "params": {
        "groups": [
            {
                "groupid": "6"
            }
        ],
        "hosts": [
            {
                "hostid": "30050"
            }
        ]
    },
    "auth": "f223adf833b2bf2ff38574a67bba6372",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "groupids": [
            "6",
        ]
    },
    "id": 1
}
```

[comment]: # ({/5592a524-5592a524})

[comment]: # ({a1410648-a1410648})
### See also

-   [hostgroup.update](update)
-   [hostgroup.massadd](massadd)
-   [Host](/manual/api/reference/host/object#host)
-   [Template](/manual/api/reference/template/object#template)

[comment]: # ({/a1410648-a1410648})

[comment]: # ({243072aa-243072aa})
### Source

CHostGroup::massUpdate() in
*ui/include/classes/api/services/CHostGroup.php*.

[comment]: # ({/243072aa-243072aa})
