[comment]: # translation:outdated

[comment]: # ({36f834f7-36f834f7})
# template.update

[comment]: # ({/36f834f7-36f834f7})

[comment]: # ({c65d8691-f8425904})
### Beschrijving

`object template.update(object/array templates)`

Deze methode maakt het mogelijk om bestaande sjablonen bij te werken.

::: noteclassic
Deze methode is alleen beschikbaar voor gebruikers met het type *Admin* en *Super admin*. Rechten om deze methode aan te roepen kunnen worden ingetrokken in de instellingen van gebruikersrollen. Zie [Gebruikersrollen](/manual/web_interface/frontend_sections/users/user_roles) voor meer informatie.
:::

[comment]: # ({/c65d8691-f8425904})

[comment]: # ({94ba88a1-5d06cf34})
### Parameters

`(object/array)` Eigenschappen van het sjabloon die bijgewerkt moeten worden.

De eigenschap `templateid` moet gedefinieerd zijn voor elk sjabloon, alle andere eigenschappen zijn optioneel. Alleen de opgegeven eigenschappen worden bijgewerkt, alle andere blijven ongewijzigd.

Naast de [standaard sjablooneigenschappen](object#template) accepteert de methode de volgende parameters.

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Omschrijving|
|--|--|------|
|groups|object/array|Te vervangen [sjabloon groepen](/manual/api/reference/templategroup/object) waartoe de sjablonen behoren.<br><br>De sjabloon groepen moeten de eigenschap `groupid` gedefinieerd hebben.|
|tags|object/array|[Sjabloontags](/manual/api/reference/template/object#template_tag) om de huidige sjabloontags te vervangen.|
|macros|object/array|Gebruikersmacro's om de huidige gebruikersmacro's op de opgegeven sjablonen te vervangen.|
|templates|object/array|Te vervangen [sjablonen](/manual/api/reference/template/object) die momenteel gelinkt zijn. Sjablonen die niet worden doorgegeven, worden alleen losgekoppeld.<br><br>De sjablonen moeten de eigenschap `templateid` gedefinieerd hebben.|
|templates\_clear|object/array|Te ontkoppelen en te wissen [sjablonen](/manual/api/reference/template/object) van de opgegeven sjablonen.<br><br>De sjablonen moeten de eigenschap `templateid` gedefinieerd hebben.|

[comment]: # ({/94ba88a1-5d06cf34})

[comment]: # ({dcba01c8-dcba01c8})
### Retourwaarden

`(object)` Retourneert een object dat de ID's van de bijgewerkte sjablonen bevat
onder de eigenschap `templateids`.

[comment]: # ({/dcba01c8-dcba01c8})

[comment]: # ({b41637d2-b41637d2})
### Voorbeelden

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({new-9c2469e7})
#### Changing the standard template properties

Change the technical name of the template to "Linux by Zabbix agent Custom", the visible name to "My template", and update the template description.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "template.update",
    "params": {
        "templateid": "10086",
        "host": "Linux by Zabbix agent Custom",
        "name": "My template",
        "description": "This is a custom Linux template."
    },
    "id": 1
}
```

Response:

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

[comment]: # ({/new-9c2469e7})

[comment]: # ({new-4abf6dbe})
#### Updating template groups

Replace all template groups for the given template with a different one.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "template.update",
    "params": {
        "templateid": "10086",
        "groups": [
            {
                "groupid": "24"
            } 
        ]
    },
    "id": 1
}
```


Response:

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

[comment]: # ({/new-4abf6dbe})

[comment]: # ({6329c800-e7972b69})
#### Bijwerken van sjabloontags

Vervang alle sjabloontags door een nieuwe tag.

[Aanvraag](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "template.update",
    "params": {
        "templateid": "10086",
        "tags": [
            {
                "tag": "Hostnaam",
                "value": "{HOST.NAME}"
            }
        ]
    },
    "id": 1
}
```

Reactie:

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

[comment]: # ({/6329c800-e7972b69})

[comment]: # ({new-d60a6434})
#### Updating template macros

Replace all template macros with a different one.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "template.update",
    "params": {
        "templateid": "10086",
        "macros": [
            {
                "macro": "{$MY_MACRO}",
                "value": "new_value"
            }
        ]
    },
    "id": 1
}
```

Response:

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

[comment]: # ({/new-d60a6434})

[comment]: # ({new-7e994e6d})
#### Updating template linked templates

Unlink (without clearing) all templates from the given template and link a different one to it.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "template.update",
    "params": {
        "templateid": "10086",
        "templates": [
            {
                "templateid": "10087"
            }
        ]
    },
    "id": 1
}
```

Response:

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

[comment]: # ({/new-7e994e6d})

[comment]: # ({new-993f083e})
#### Clearing template linked templates

Unlink and clear the given template from a specific linked template.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "template.update",
    "params": {
        "templateid": "10086",
        "templates_clear": [
            {
                "templateid": "10087"
            }
        ]
    },
    "id": 1
}
```

Response:

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

[comment]: # ({/new-993f083e})

[comment]: # ({eb72cc1c-eb72cc1c})
### Bron

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

[comment]: # ({/eb72cc1c-eb72cc1c})
