update_notification

The update_notification method is used to create, edit, or delete notifications.

Copied!
svc = "resource/update_notification"
params = {
  "itemId": <long>,
  "id": <long>,  // Notification ID
  "callMode": "<text>",
  "e": <bool>,
  "n": "<text>",  // Name
  "txt": "<text>",  // Notification text
  "ta": <uint>,  // Activation time (Unix format)
  "td": <uint>,  // Deactivation time (Unix format)
  "ma": <uint>,  // Maximum number of alarms (0 = unlimited)
  "mmtd": <uint>,  // Max time interval between messages (sec)
  "cdt": <uint>,  // Alarm timeout (sec)
  "mast": <uint>,  // Min duration of alarm state (sec)
  "mpst": <uint>,  // Min duration of previous state (sec)
  "cp": <uint>,  // Control period relative to current time (sec)
  "fl": <uint>,  // Notification flags
  "tz": <int>,  // Time zone
  "la": "<text>",  // User language (2-letter code)
  "un": [<long>],  // Array of unit or unit group IDs
  "d": "<text>",  // Notification description
  "sch": {  // Notification schedule
    "f1": <uint>,  // Interval 1 start (minutes from midnight)
    "f2": <uint>,  // Interval 2 start (minutes from midnight)
    "t1": <uint>,  // Interval 1 end (minutes from midnight)
    "t2": <uint>,  // Interval 2 end (minutes from midnight)
    "m": <uint>,  // Day-of-month mask
    "y": <uint>,  // Month mask
    "w": <uint>   // Day-of-week mask
  },

  "ctrl_sch": {  // Max alarms control schedule
    "f1": <uint>,
    "f2": <uint>,
    "t1": <uint>,
    "t2": <uint>,
    "m": <uint>,
    "y": <uint>,
    "w": <uint>
  },

  "trg": {  // Trigger
    "t": "<text>",
    "p": {
      "<text>": "<text>",
      ...
    }
  },

  "act": [  // Actions
    {
      "t": "<text>",  // Action type
      "p": {
        "<text>": "<text>",  // Parameters
        ...
      }
    }
  ]
}

See the description of notification flags and action types on the get_notification_data page.

For notifications of the Off time control type, the value of the mast parameter specified in seconds must correspond to the value of the min_idle_time parameter specified in minutes. Thus, if you want the notification to be triggered after 10 minutes of off time, specify 10 for min_idle_time and 600 for mast.

Parameters

Name Description
itemId Resource ID.
id Notification ID (0 to create).
callMode Action: create, update, delete, enable.
e Used only for the “enable” callMode:

  • false or 0: disable;
  • true or 1: enable.
d Notification description. Optional. If you omit this parameter when updating a notification, the description is cleared. To keep the description, pass its current value.

Other parameters are only required for creating and updating. See the get_notification_data page.

Units and unit groups specified in the un parameter are added to the notification only if the creator of the resource has the Use unit in jobs, notifications, routes, retranslators access right to them. Other units are skipped without an error.

Returned result

For creation and modification requests:

Copied!
[
	<long>,				/* notification ID */
	{
		"id":<long>,	/* notification ID */
		"n":"<text>",		/* name */
		"txt":"<text>",	/* notification text */
		"ta":<uint>,	/* activation time (Unix format) */
		"td":<uint>,	/* deactivation time (Unix format) */
		"ma":<uint>,	/* maximum alarms count (0: unlimited) */
		"fl":<uint>,	/* notification flags */
		"ac":<uint>,	/* execution count */
		"un":[<long>],	/* array of units/unit group IDs */
		"act":["<text>"],	/* actions */
		"trg":"<text>",	/* control type */
		"trg_p":{},		/* control settings */
		"crc":<long>,	/* checksum of the binary representation of notification */ 
		"ct":<uint>,    /* creation time */  
		"mt":<uint>     /* last modification time */
	}
]

Notification flags, action, and control types are described here.

For deletion requests:

Copied!
[
	<long>,		/* notification ID */
	null
]

Possible error codes:

Code Description
7 The resource doesn’t exist, or the user doesn’t have the Create, edit, and delete notifications access right to it.
6 Undefined error.
4 Wrong input parameters.

If you find a mistake in the text, please select it and press Ctrl+Enter.