[comment]: # ({a7242998-a7242998})
# template.delete

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

[comment]: # ({f2213dc2-484b4ad2})
### 描述

`object template.delete(array templateIds)`

此方法允许delete模板。

删除模板将导致删除所有模板实体（监控项、
触发器、图形等）。若希望保留模板实体所属的主机，但
delete模板本身，请首先使用以下方法之一将模板从所需的
主机中解除关联：
[template.update](/manual/api/reference/template/update)、
[template.massupdate](/manual/api/reference/template/massupdate)、
[host.update](/manual/api/reference/host/update)、
[host.massupdate](/manual/api/reference/host/massupdate)。

::: noteclassic
此方法仅对 *Admin（管理员）* 和 *Super admin（超级管理员）*
用户类型可用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参见
[User
roles](/manual/web_interface/frontend_sections/users/user_roles)。
:::

[comment]: # ({/f2213dc2-484b4ad2})

[comment]: # ({1fbebaa3-1fbebaa3})
### 参数

`(array)` 要删除的模板的 IDs。

[comment]: # ({/1fbebaa3-1fbebaa3})

[comment]: # ({fdd33aa6-fdd33aa6})
### 返回值

`(object)` 返回一个 object，其中包含在 `templateids` 属性下删除的模板的 ID。

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

[comment]: # ({b41637d2-b41637d2})
### 示例

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

[comment]: # ({e1eb8f52-3c8960bb})
#### 删除多个模板

删除两个模板。

[执行请求](/manual/api#执行请求):


```json
{
    "jsonrpc": "2.0",
    "method": "template.delete",
    "params": [
        "13",
        "32"
    ],
    "id": 1
}
```
响应：


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

[comment]: # ({/e1eb8f52-3c8960bb})

[comment]: # ({bfde186e-bfde186e})
### 来源

CTemplate::delete() 方法位于 *ui/include/classes/api/services/CTemplate.php* 文件中。

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