This method allows to create new actions.
This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See for more information.
Parameters
(object/array)
Actions to create.
Additionally to the , the method accepts the following parameters.
(object)
Returns an object containing the IDs of the created actions under the actionids
property. The order of the returned IDs matches the order of the passed actions.
Examples
Create a trigger action
Create an action that will be run when a trigger from host “30045” that has the word “memory” in its name goes into problem state. The action must first send a message to all users in user group “7”. If the event is not resolved in 4 minutes, it will run script “3” on all hosts in group “2”. On trigger recovery it will notify all users who received any messages regarding the problem before. On trigger update, message with custom subject and body will be sent to all who left acknowledgments and comments via all media types.
Response:
{
"jsonrpc": "2.0",
"result": {
"actionids": [
"17"
},
"id": 1
}
Create a discovery action
Create an action that will link discovered hosts to template “30085”.
Request:
Response:
"jsonrpc": "2.0",
"result": {
"actionids": [
"18"
]
},
"id": 1
}
Using a custom expression filter
Create a trigger action that will use a custom filter condition. The action must send a message for each trigger with severity higher or equal to “Warning” for hosts “10084” and “10106”. The formula IDs “A”, “B” and “C” have been chosen arbitrarily.
Request:
{
"jsonrpc": "2.0",
"result": {
]
},
"id": 1
}
Create agent autoregistration rule
Add a host to host group “Linux servers” when host name contains “SRV” or metadata contains “CentOS”.
Request:
Response:
{
"jsonrpc": "2.0",
"result": {
"actionids": [
19
]
},
"id": 1
Source
CAction::create() in ui/include/classes/api/services/CAction.php.