[comment]: # translation:outdated

[comment]: # ({a7242998-a7242998})
# 删除

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

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

`object template.delete(array templateIds)`

这个方法可以删除模版。

删除模板将导致删除所有模板实体（监控项、触发器、图形等）。如果要保留模板实体与主机关联，但删除模板本身，请先使用以下方法将模板从必要的主机中取消关联:
[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
这个方法只有 *管理员* 和 *超级管理员* 用户可用。在用户角色设置中可用撤销掉用该方法的权限。 查看 [用户角色](/manual/web_interface/frontend_sections/users/user_roles)获取更多信息。
:::

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

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

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

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

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

`(object)` 返回一个对象，该对象包含`templateids`属性下已删除模板的ID。

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

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

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

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

删除2个模版。

[请求](/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})
