This is the documentation page for an unsupported version of Zabbix.
Is this not what you were looking for? Switch to the current version or choose one from the drop-down menu.

template.massadd

Description

object template.massadd(object parameters)

This method allows to simultaneously add multiple related objects to the given templates.

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.

Parameters

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

The method accepts the following parameters.

Parameter Type Description
templates
(required)
object/array Templates to be updated.

The templates must have the templateid property defined.
groups object/array Template groups to add the given templates to.

The template groups must have the groupid property defined.
macros object/array User macros to be created for the given templates.
templates_link object/array Templates to link to the given templates.

The templates must have the templateid property defined.

Return values

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

Examples

Add template group "2" to two templates.

Request:

{
           "jsonrpc": "2.0",
           "method": "template.massadd",
           "params": {
               "templates": [
                   {
                       "templateid": "10085"
                   },
                   {
                       "templateid": "10086"
                   }
               ],
               "groups": [
                   {
                       "groupid": "2"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

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

Link templates "10106" and "10104" to template.

Request:

{
           "jsonrpc": "2.0",
           "method": "template.massadd",
           "params": {
               "templates": [
                   {
                       "templateid": "10073"
                   }
               ],
               "templates_link": [
                   {
                       "templateid": "10106"
                   },
                   {
                       "templateid": "10104"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10073"
               ]
           },
           "id": 1
       }

See also

Source

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