object template.update(object/array templates)
This method allows to update existing 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.
(object/array)
Template properties to be updated.
The templateid
property must be defined for each template, all other properties are optional. Only the given properties will be updated, all others will remain unchanged.
Additionally to the standard template properties, the method accepts the following parameters.
Parameter | Type | Description |
---|---|---|
groups | object/array | Template groups to replace the current template groups the templates belong to. The template groups must have only the groupid property defined. |
tags | object/array | Template tags to replace the current template tags. |
macros | object/array | User macros to replace the current user macros on the given templates. |
templates | object/array | Templates to replace the currently linked templates. Templates that are not passed are only unlinked. The templates must have only the templateid property defined. |
templates_clear | object/array | Templates to unlink and clear from the given templates. The templates must have only the templateid property defined. |
(object)
Returns an object containing the IDs of the updated templates under the templateids
property.
Rename the template to "Template OS Linux".
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"name": "Template OS Linux"
},
"id": 1
}
Response:
Replace all template tags with a new one.
{
"jsonrpc": "2.0",
"method": "template.update",
"params": {
"templateid": "10086",
"tags": [
{
"tag": "Host name",
"value": "{HOST.NAME}"
}
]
},
"id": 1
}
Response:
CTemplate::update() in ui/include/classes/api/services/CTemplate.php.