This method allows to update existing hosts.
This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See for more information.
Parameters
(object/array)
Host properties to be updated.
The hostid
property must be defined for each host, all other properties are optional. Only the given properties will be updated, all others will remain unchanged.
Note, however, that updating the host technical name will also update the host’s visible name (if not given or empty) by the host’s technical name value.
Additionally to the , the method accepts the following parameters.
As opposed to the Zabbix frontend, when name
(visible host name) is the same as host
(technical host name), updating host
via API will not automatically update name
. Both properties need to be updated explicitly.
(object)
Returns an object containing the IDs of the updated hosts under the hostids
property.
Examples
Enabling a host
Enable host monitoring, i.e. set its status to 0.
Request:
{
"jsonrpc": "2.0",
"result": {
"hostids": [
"10126"
]
},
"id": 1
}
Unlinking templates
Unlink and clear two templates from host.
Request:
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10126",
"templates_clear": [
{
"templateid": "10124"
{
"templateid": "10125"
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
Updating host macros
Replace all host macros with two new ones.
Request:
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10126",
"macros": [
{
"macro": "{$PASS}",
"value": "password"
},
{
"macro": "{$DISC}",
"value": "sda",
"description": "Updated description"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
"jsonrpc": "2.0",
"result": {
"hostids": [
"10126"
]
"id": 1
}
Updating host inventory
Change inventory mode and add location
Request:
Response:
{
"jsonrpc": "2.0",
"result": {
"hostids": [
"10387"
]
},
"id": 1
}
Updating host tags
Replace all host tags with a new one.
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10387",
"tags": {
"tag": "OS",
"value": "CentOS 7"
}
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
}
Response: