You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.



object host.massadd(object parameters)

This method allows to simultaneously add multiple related objects to all the given 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 User roles for more information.


(object) Parameters containing the IDs of the hosts to update and the objects to add to all the hosts.

The method accepts the following parameters.

Parameter Type Description
hosts object/array Hosts to be updated.

The hosts must have only the hostid property defined.

Parameter behavior:
- required
groups object/array Host groups to add to the given hosts.

The host groups must have only the groupid property defined.
interfaces object/array Host interfaces to be created for the given hosts.
macros object/array User macros to be created for the given hosts.
templates object/array Templates to link to the given hosts.

The templates must have only the templateid property defined.

Return values

(object) Returns an object containing the IDs of the updated hosts under the hostids property.


Adding macros

Add two new macros to two hosts.


           "jsonrpc": "2.0",
           "method": "host.massadd",
           "params": {
               "hosts": [
                       "hostid": "10160"
                       "hostid": "10167"
               "macros": [
                       "macro": "{$TEST1}",
                       "value": "MACROTEST1"
                       "macro": "{$TEST2}",
                       "value": "MACROTEST2",
                       "description": "Test description"
           "id": 1


           "jsonrpc": "2.0",
           "result": {
               "hostids": [
           "id": 1

See also


CHost::massAdd() in ui/include/classes/api/services/CHost.php.