This is the documentation page for an unsupported version of Zabbix.
Is this not what you were looking for? Switch to the current version or choose one from the drop-down menu.

action.create

Description

object action.create(object/array actions)

This method allows to create new actions.

Parameters

(object/array) Actions to create.

Additionally to the standard action properties, the method accepts the following parameters.

Parameter Type Description
operations
(required)
array Action operations to create for the action.
conditions array Action conditions to create for the action.

Return values

(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".

Request:

{
           "jsonrpc": "2.0",
           "method": "action.create",
           "params": {
               "name": "Trigger action",
               "eventsource": 0,
               "evaltype": 0,
               "status": 0,
               "esc_period": 120,
               "def_shortdata": "{TRIGGER.NAME}: {TRIGGER.STATUS}",
               "def_longdata": "{TRIGGER.NAME}: {TRIGGER.STATUS}\r\nLast value: {ITEM.LASTVALUE}\r\n\r\n{TRIGGER.URL}",
               "conditions": [
                   {
                       "conditiontype": 1,
                       "operator": 0,
                       "value": "30045"
                   },
                   {
                       "conditiontype": 3,
                       "operator": 2,
                       "value": "memory"
                   }
               ],
               "operations": [
                   {
                       "operationtype": 0,
                       "esc_period": 0,
                       "esc_step_from": 1,
                       "esc_step_to": 2,
                       "evaltype": 0,
                       "opmessage_grp": [
                           {
                               "usrgrpid": "7"
                           }
                       ],
                       "opmessage": {
                           "default_msg": 1,
                           "mediatypeid": "1"
                       }
                   },
                   {
                       "operationtype": 1,
                       "esc_step_from": 3,
                       "esc_step_to": 4,
                       "evaltype": 0,
                       "opconditions": [
                           {
                               "conditiontype": 14,
                               "operator": 0,
                               "value": "0"
                           }
                       ],
                       "opcommand_grp": [
                           {
                               "groupid": "2"
                           }
                       ],
                       "opcommand": {
                           "type": 4,
                           "scriptid": "3"
                       }
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

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:

{
           "jsonrpc": "2.0",
           "method": "action.create",
           "params": {
               "name": "Discovery action",
               "eventsource": 1,
               "status": 0,
               "esc_period": 0,
               "evaltype": 0,
               "conditions": [
                   {
                       "conditiontype": 21,
                       "value": "1"
                   },
                   {
                       "conditiontype": 10,
                       "value": "2"
                   }
               ],
               "operations": [
                   {
                       "esc_step_from": 1,
                       "esc_period": 0,
                       "optemplate": [
                           {
                               "templateid": "30085"
                           }
                       ],
                       "operationtype": 6,
                       "esc_step_to": 1
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "actionids": [
                   "18"
               ]
           },
           "id": 1
       }

See also

Source

CAction::create() in frontends/php/api/classes/CAction.php.