[comment]: # translation:outdated

[comment]: # ({49f9e765-49f9e765})
# 创建触发器原型

[comment]: # ({/49f9e765-49f9e765})

[comment]: # ({ef08f220-c66bc66b})
### 描述

`object triggerprototype.create(object/array triggerPrototypes)`

此方法允许创建新的触发器原型.

::: noteclassic
此方法只适用于Admin和Super admin用户类型，调用该方法的权限可以在用户角色设置中被撤销. 前往 [用户角色](/manual/web_interface/frontend_sections/administration/user_roles) 以查看并了解更多信息.
:::

[comment]: # ({/ef08f220-c66bc66b})

[comment]: # ({2a1e778b-e93145a6})
### 参数

`(object/array)` 创建触发器原型.

除了 [标准触发器原型属性](object#trigger_prototype) 此方法还接受以下参数.

| 参数         | [类型](/manual/api/reference_commentary#data_types) | 描述                                                         |
| ------------ | --------------------------------------------------- | ------------------------------------------------------------ |
| dependencies | array                                               | 触发器原型所依赖的触发器和触发器原型.<br><br>触发器必须已定义`triggerid`属性. |
| tags         | array                                               | 触发器 [标签](/manual/api/reference/triggerprototype/object#trigger_prototype_tag). |

::: noteimportant
指定的触发器表达式必须为展开式，并且必须包含至少一个监控项原型.
:::

[comment]: # ({/2a1e778b-e93145a6})

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

`(object)`返回一个对象，该对象包含在`triggerids`属性中已创建触发器原型的ID，返回ID的顺序与传递触发器原型的顺序相匹配.

[comment]: # ({/8d1f4c4d-8d1f4c4d})

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

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

[comment]: # ({4799837f-87a61295})
#### 创建触发器原型

创建一个触发器原型来检测磁盘剩余空间是否小于20%.

请求:

```json
{
    "jsonrpc": "2.0",
    "method": "triggerprototype.create",
    "params": {
        "description": "Free disk space is less than 20% on volume {#FSNAME}",
        "expression": "last(/Zabbix server/vfs.fs.size[{#FSNAME},pfree])<20",
        "tags": [
            {
                "tag": "volume",
                "value": "{#FSNAME}"
            },
            {
                "tag": "type",
                "value": "{#FSTYPE}"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "triggerids": [
            "17372"
        ]
    },
    "id": 1
}
```

[comment]: # ({/4799837f-87a61295})

[comment]: # ({43cf23db-43cf23db})
### 源码

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

[comment]: # ({/43cf23db-43cf23db})
