[comment]: # translation:outdated

[comment]: # ({56486046-56486046})
# trigger.create

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

[comment]: # ({2fa756eb-8efa90c6})
### 説明

`object trigger.create(object/array triggers)`

このメソッドで、新しいトリガーを作成できます。

::: noteclassic
このメソッドは*Admin*および*Super admin*ユーザータイプでのみ使用できます。 メソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。 詳細については[ユーザーの役割](/manual/web_interface/frontend_sections/administration/user_roles)を参照してください。
:::

[comment]: # ({/2fa756eb-8efa90c6})

[comment]: # ({879a272f-c2c3e90f})
### パラメータ

`(object/array)` 作成するトリガー

このメソッドは[標準トリガー プロパティ](object#trigger) に加えて、次のパラメーターを受け入れます。

|パラメータ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|dependencies|array|トリガーが依存するトリガー<br><br>トリガーには `triggerid` プロパティが定義されている必要があります。|
|tags|array|トリガー [タグ](/manual/api/reference/trigger/object#trigger_tag)|

::: noteimportant
トリガー式は、展開された形式で指定する必要があります。
:::

[comment]: # ({/879a272f-c2c3e90f})

[comment]: # ({4938d22d-4938d22d})
### 戻り値

`(object)` `triggerids` プロパティの下で作成されたトリガーの ID を含むオブジェクトを返します。 返される ID の順序は、渡されたトリガーの順序と一致します。

[comment]: # ({/4938d22d-4938d22d})

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

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

[comment]: # ({c3aae372-f57689d3})
#### トリガーの作成

単一のトリガー依存関係を持つトリガーを作成します

Request:

```json
{
    "jsonrpc": "2.0",
    "method": "trigger.create",
    "params": [
        {
            "description": "Processor load is too high on {HOST.NAME}",
            "expression": "last(/Linux server/system.cpu.load[percpu,avg1])>5",
            "dependencies": [
                {
                    "triggerid": "17367"
                }
            ]
        },
        {
            "description": "Service status",
            "expression": "length(last(/Linux server/log[/var/log/system,Service .* has stopped]))<>0",
            "dependencies": [
                {
                    "triggerid": "17368"
                }
            ],
            "tags": [
                {
                    "tag": "service",
                    "value": "{{ITEM.VALUE}.regsub(\"Service (.*) has stopped\", \"\\1\")}"
                },
                {
                    "tag": "error",
                    "value": ""
                }
            ]
        }
    ],
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

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

[comment]: # ({/c3aae372-f57689d3})

[comment]: # ({7d49da78-7d49da78})
### ソース

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

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