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.

template.create

Description

object template.create(object/array templates)

This method allows to create new 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/array) Templates to create.

Additionally to the standard template properties, the method accepts the following parameters.

Parameter Type Description
groups object/array Template groups to add the template to.

The template groups must have only the groupid property defined.

Parameter behavior:
- required
tags object/array Template tags.
templates object/array Templates to be linked to the template.

The templates must have only the templateid property defined.
macros object/array User macros to be created for the template.

Return values

(object) Returns an object containing the IDs of the created templates under the templateids property. The order of the returned IDs matches the order of the passed templates.

Examples

Creating a template

Create a template with tags and link two templates to this template.

Request:

{
           "jsonrpc": "2.0",
           "method": "template.create",
           "params": {
               "host": "Linux template",
               "groups": {
                   "groupid": 1
               },
               "templates": [
                   {
                       "templateid": "11115"
                   },
                   {
                       "templateid": "11116"
                   }
               ],
               "tags": [
                   {
                       "tag": "host-name",
                       "value": "{HOST.NAME}"
                   }
               ]
           },
           "id": 1
       }

Response:

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

Source

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