Notification Rule API (Deprecated)

πŸ“˜

Create an API Integration and obtain your apiKey to make requests listed below.

You can refer Notification Settings for detailed information about the notification rules and their steps.

Notification Rule API Requests

Add Notification Rule Request

Add Notification Rule request is used to add a new notification rule to the specified user in OpsGenie.

🚧

Adding a notification rule with step(s) is not supported. You should create a notification rule without its steps first and then configure the steps by using the Notification Rule Step API requests to achieve this.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
nameName of the notification rule.
actionTypeType of the action that notification rule will have. Should be one of New Alert, Acknowledged Alert, Closed Alert, Schedule Start, Renotified Alert, Assigned Alert, Add Note, Schedule End.
conditionMatchTypeType of the operation will be applied on conditions. Should be one of Match All, Match Any Condition, Match All Conditions
conditionsList of conditions will be checked before applying notification rule. Mandatory when actionType is not Schedule Start/End and conditionMatchType is Match Any Condition or Match All Conditions. You can refer here for more about the parameter definition.
notifyBeforeList of Time Periods that notification for schedule start/end will be sent. Mandatory for Schedule Start/End rules. Can be Just Before, 15 mins, 1 hour, 1 day

Optional Parameters

Parameter
applyOrderThe order of the notification rule within the notification rules with the same action type. applyOrder value is actually the index of the notification rule whose minimum value is 0 and whose maximum value is n-1 where the number of notification rules with the same action type is n. If the number of notification rules with the given type is greater than or equal to applyOrder value, the behavior will be the same as not providing this parameter.
restrictionsTime interval that notification rule will work. It can be just one restriction which will be applied all days, or list of restrictions will be applied to the specified days. You may refer here for more about the parameter definition.
schedulesThis field is valid for Schedule Start/End rules. It can be list of schedule names/ids that notification rule will be applied when on call of that schedule starts/ends. This field shall only be populated with the specified user's schedules.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule' -d '

{
    "username":"[email protected]",
    "name": "New Alert Night",
    "actionType": "New Alert",
    "conditionMatchType": "Match All Conditions",
    "conditions": [
        {
            "not": "false",
            "field": "message",
            "operation": "contains",
            "expectedValue": "night"
        },
        {
            "not": "true",
            "field": "extraProperties",
            "operation": "contains Key",
            "expectedValue": "prop1"
        }

    ],
    "restrictions":{
        "startHour":"15",
        "startMinute":"04",
        "endHour":"18",
        "endMinute":"58"
    }
}'

Response:

{
     "id" : "d609c2d4-c7e0-4c3c-b339-40bb58f89963",
     "status" : "successful",
     "code" : 200
}

Sample Schedule Start Notification Rule Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule' -d '
{
    "username":"[email protected]",
    "name": "Schedule Start",
    "actionType": "Schedule Start",
    "schedules": ["network_team_schedule"],
    "notifyBefore": ["Just Before", "15 Mins"],
    "restrictions":[
        {
            "startHour":"15",
            "startMinute":"04",
            "endHour":"18",
            "endMinute":"58",
            "startDay":"Monday",
            "endDay": "Tuesday"
        },
        {
            "startHour":"10",
            "startMinute":"00",
            "endHour":"18",
            "endMinute":"15",
            "startDay":"Wednesday",
            "endDay": "Thursday"
        }
    ]
}

Response:

{
    "code": 200,
    "id": "56be7184-94d9-4335-b8d6-c3cab63f9455",
    "status": "successful"
}

Update Notification Rule Request

Update Notification Rule request is used to update notification rules of users in OpsGenie.

🚧

Updating notification rule with steps is not supported.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
idId of the notification rule will be updated.

Optional Parameters

Parameter
nameName of the notification rule.
conditionMatchTypeType of the operation will be applied on conditions.
conditionsList of conditions will be checked before applying notification rule. You can refer here for more about the parameter definition.
notifyBeforeList of Time Periods that notification for schedule start will be sent.
restrictionsTime interval that notification rule will work. To remove all restrictions, this field should be populated with empty object ({}) or empty list ([]). You may refer here for more about the parameter definition.
schedulesThis field is valid for Schedule Start rules. It can be list of schedule names/ids that notification rule will be applied when on call of that schedule starts. This field shall only be populated with the users schedules.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule' -d '

{
    "username":"[email protected]",
    "id" : "d609c2d4-c7e0-4c3c-b339-40bb58f89963",
    "conditionMatchType": "Match All",
    "restrictions":{}
}'

Response:

{
     "id" : "d609c2d4-c7e0-4c3c-b339-40bb58f89963",
     "status" : "successful",
     "code" : 200
}

Sample Schedule Start Notification Rule Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule' -d '
{
    "username":"[email protected]",
    "id": "56be7184-94d9-4335-b8d6-c3cab63f9455",
    "schedules": [],
    "restrictions":[]
}

Response:

{
    "code": 200,
    "id": "56be7184-94d9-4335-b8d6-c3cab63f9455",
    "status": "successful"
}

Delete Notification Rule Request

Delete Notification Rule request is used to delete notification rules of users in OpsGenie.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
idId of notification rule will be deleted.

Sample Request

curl -XDELETE 'https://api.opsgenie.com/v1/json/user/notificationRule?apiKey=eb243592-faa2-4ba2-a551q-1afdf565c889&[email protected]&id=57d6bdbc-6ad2-4366-8438-6d1f4e10fb60'

Response:

{
  "code": 200,
  "status": "successful"
}

Enable Notification Rule Request

Enable Notification Rule request is used to enable notification rules of users in OpsGenie.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
idId of notification rule will be enabled.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/enable?apiKey=eb243592-faa2-4ba2-a551q-1afdf565c889' -d '
{
    "username": "[email protected]",
    "id": "8f38dcfb-b5ff-48ce-bedb-6322681eacb6"
}'

Response:

{
  "status": "success"
}

Disable Notification Rule Request

Disable Notification Rule request is used to disable notification rules of users in OpsGenie.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
idId of notification rule will be disabled.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/disable?apiKey=eb243592-faa2-4ba2-a551q-1afdf565c889' -d '
{
    "username": "[email protected]",
    "id": "8f38dcfb-b5ff-48ce-bedb-6322681eacb6"
}'

Response:

{
  "status": "success"
}

Change Notification Rule Order Request

Change Notification Rule Order Request is used to change the appliance order of the notification rule within the notification rules with same action type.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
idId of the notification rule whose appliance order will be updated.
applyOrderThe new order of the notification rule within the notification rules of same action type. applyOrder value is actually the index of the notification rule whose minimum value is 0 and whose maximum value is n-1 where the number of notification rules with the same action type is n.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/changeOrder?apiKey=eb243592-faa2-4ba2-a551q-1afdf565c889' -d '
{
    "username": "[email protected]",
    "id": "8f38dcfb-b5ff-48ce-bedb-6322681eacb6",
    "applyOrder" : 1
}'

Response:

{
  "status": "success"
}

Repeat Notification Rule Request

Repeat Notification Rule request is used to repeat notification rules of users in OpsGenie.

πŸ“˜

Repeat option is only valid for New Alert Notification Rules

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
idId of notification rule will be repeated.
loopAfterThe amount of time in minutes that notification steps will be repeatedly apply. If enabled parameter is specified with true, loopAfter parameter should also be specified. You may refer Notification Settings for further information about repeating.

Optional Parameters

Parameter
enabledBoolean value that will decide whether repeating is enabled or not. Possible values are true and false.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/repeat?apiKey=eb243592-faa2-4ba2-a551q-1afdf565c889' -d '
{
    "username": "[email protected]",
    "id": "8f38dcfb-b5ff-48ce-bedb-6322681eacb6",
    "loopAfter":"5"
}'

Response

{
  "status": "success"
}

Get Notification Rule Request

πŸ“˜

This is a read request. Therefore, even if the integration of the API key is configured as read-only, the request will be accepted.

Get Notification Rule request is used to retrieve notification rule details of users in OpsGenie. It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
idId of the notification rule that will be retrieved.
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.

Sample Request

curl -XGET 'https://api.opsgenie.com/v1/json/user/notificationRule?apiKey=ba503523-f94c-4adb-a2f4-376e99f68885&[email protected]&id=67c4855a-4c1b-4cbf-9be2-87eb212760e9

Response:

{
  "actionType": "New Alert",
  "name": "New Alert",
  "restrictions": {
    "endHour": 18,
    "startHour": 0,
    "startMinute": 0,
    "endMinute": 0
  },
  "id": "67c4855a-4c1b-4cbf-9be2-87eb212760e9",
  "conditions": [
    {
      "not": false,
      "field": "message",
      "expectedValue": "new",
      "operation": "Contains"
    },
    {
      "not": false,
      "field": "actions",
      "expectedValue": "ping",
      "operation": "Contains"
    }
  ],
  "steps": [
    {
      "method": "voice",
      "to": "1-9999999999",
      "id": "6419cef5-ca1f-4842-9ddc-518952c60c2b",
      "sendAfter": 0,
      "enabled": true
    }
  ],
  "enabled": true,
  "conditionMatchType": "Match All Conditions",
  "loopAfter": 0
}

Sample Request for Schedule Start Notification Rule

curl -XGET 'https://api.opsgenie.com/v1/json/user/notificationRule?apiKey=ba503523-f94c-4adb-a2f4-376e99f68885&[email protected]&id=5ef5cc7f-23f4-4168-9f0f-d543d0c325b4
{
  "actionType": "Schedule Start",
  "schedules": [
    "network_team_schedule"
  ],
  "name": "Schedule Start",
  "notifyBefore": [
    "Just Before",
    "15 mins"
  ],
  "restrictions": [
    {
      "endHour": 0,
      "startDay": "SUNDAY",
      "startHour": 0,
      "endDay": "MONDAY",
      "startMinute": 0,
      "endMinute": 0
    }
  ],
  "id": "5ef5cc7f-23f4-4168-9f0f-d543d0c325b4",
  "steps": [
    {
      "method": "email",
      "to": "[email protected]",
      "id": "2dae31b1-5e89-4c33-a05f-d1f0e746c4db",
      "sendAfter": 0,
      "enabled": true
    }
  ],
  "enabled": true
}

List Notification Rules Request

πŸ“˜

This is a read request. Therefore, even if the integration of the API key is configured as read-only, the request will be accepted.

List Notification Rule request is used to retrieve all notification rules with details of users in OpsGenie. It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.

Sample Request

curl -XGET 'https://api.opsgenie.com/v1/json/user/notificationRule?apiKey=ba503523-f94c-4adb-a2f4-376e99f68885&[email protected]

Response:

{
  "rules": [
    {
      "actionType": "Schedule Start",
      "applyOrder": 0,
      "schedules": [
        "network_team_schedule"
      ],
      "name": "Schedule Start",
      "notifyBefore": [
        "Just Before",
        "15 mins"
      ],
      "restrictions": [
        {
          "endHour": 0,
          "startDay": "SUNDAY",
          "startHour": 0,
          "endDay": "MONDAY",
          "startMinute": 0,
          "endMinute": 0
        }
      ],
      "id": "5ef5cc7f-23f4-4168-9f0f-d543d0c325b4",
      "steps": [
        {
          "method": "email",
          "to": "[email protected]",
          "id": "2dae31b1-5e89-4c33-a05f-d1f0e746c4db",
          "sendAfter": 0,
          "enabled": true
        }
      ],
      "enabled": true
    },
    {
      "actionType": "New Alert",
      "applyOrder": 0,
      "name": "New Alert",
      "restrictions": {
        "endHour": 18,
        "startHour": 0,
        "startMinute": 0,
        "endMinute": 0
      },
      "id": "67c4855a-4c1b-4cbf-9be2-87eb212760e9",
      "conditions": [
        {
          "not": false,
          "field": "message",
          "expectedValue": "new",
          "operation": "Contains"
        },
        {
          "not": false,
          "field": "actions",
          "expectedValue": "ping",
          "operation": "Contains"
        }
      ],
      "steps": [
        {
          "method": "voice",
          "to": "1-9999999999",
          "id": "6419cef5-ca1f-4842-9ddc-518952c60c2b",
          "sendAfter": 0,
          "enabled": true
        }
      ],
      "enabled": true,
      "conditionMatchType": "Match All Conditions",
      "loopAfter": 0
    },
    {
      "actionType": "New Alert",
      "applyOrder": 1,
      "name": "New Alert Night",
      "restrictions": {
        "endHour": 18,
        "startHour": 15,
        "startMinute": 4,
        "endMinute": 58
      },
      "id": "d609c2d4-c7e0-4c3c-b339-40bb58f89963",
      "conditions": [
        {
          "not": false,
          "field": "message",
          "expectedValue": "asdf",
          "operation": "Equals"
        },
        {
          "not": true,
          "field": "extraProperties",
          "expectedValue": "asdf",
          "operation": "Contains Key"
        }
      ],
      "steps": [
        {
          "method": "email",
          "to": "[email protected]",
          "id": "bd96aa09-e161-4c7e-8d15-ba5e55b7b1e2",
          "sendAfter": 5,
          "enabled": true
        }
      ],
      "enabled": true,
      "conditionMatchType": "Match All Conditions",
      "loopAfter": 5
    }
  ]
}

Parameters of Conditions

conditions field should contain list of condition objects. condition objects should have the following format:

Parameter
not
fieldAlert field will be checked for the condition.Available fields: message, alias, description, source, entity, tags, actions, extraProperties, recipients, teams.
operationCondition Operation which will be applied when comparing alert field and the expected value. Available operations changes according to the fields type.

String Operations: Contains, Equals, Starts With, Ends With, Matches, Is Empty, Equals Ignore Whitespace
List Operations: Contains, Is Empty
Map Operations: Contains, Contains Key, Contains Value, Is Empty
Number Operations: Matches, Equals, Greater Than, Less Than
* Boolean Operations: Equals
expectedValueUser defined value that will be compared with alert field according to the operation

Parameters Of Restriction

Restrictions can be only one restriction object which will be applied to all weekdays, or list of restriction objects containing additional startDay and endDay info.

To get detailed information about time restrictions, you can refer to our Time Constraints and Time Zones support doc.

Parameter
startHourValue of the hour that notification rule start working.
startMinuteValue of the minute that notification rule start working.
endHourValue of the hour that notification rule end working.
endMinuteValue of the minute that notification rule end working.
startDayName of day when restriction will start. Mandatory only list of restriction objects. May be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday
endDayName of day when restriction will end. Mandatory only list of restriction objects. May be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday

Notification Rule Step API Requests

Add Notification Rule Step Request

Add Notification Rule Step request is used to add steps to notification rules in OpsGenie.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
ruleIdId of the notification rule that step will belong to.
methodMethod of the contact that notification will be sent to, should be one of email, voice or sms.
toAddress of the contact that notification will be sent to.
sendAfterMinute time period notification will be sent after. Valid and Mandatory only for New Alert and Assigned Alert notification rules.

🚧

Adding Notification Rule Step with a mobile contact is not supported.

Sample Request

{curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/step' -d '
    "username":"[email protected]",
    "ruleId":"d609c2d4-c7e0-4c3c-b339-40bb58f89963",
    "method":"email",
    "to":"[email protected]",
    "sendAfter":"5"
}

Response

{
  "code": 200,
  "id": "6680f7b3-715e-4add-86f0-690f08d31711",
  "status": "successful"
}

Update Notification Rule Step Request

Update Notification Rule Step request is used to update steps of notification rules in OpsGenie.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
ruleIdId of the notification rule that step belongs to.
idId of the rule step will be updated.

Optional Parameters

Parameter
methodMethod of the contact notification will be sent to, should be one of email, voice or sms.
toAddress of the contact notification will be sent to.
sendAfterMinute time period notification will be sent after. Valid only for New Alert and Assigned Alert notification rules.

🚧

Updating Notification Rule Step with a mobile contact is not supported.

Sample Request

{curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/step' -d '
    "username":"[email protected]",
    "ruleId":"d609c2d4-c7e0-4c3c-b339-40bb58f89963",
    "id": "6680f7b3-715e-4add-86f0-690f08d31711",
    "method":"voice",
    "to":"1-9999999999"
}

Response

{
  "code": 200,
  "id": "6680f7b3-715e-4add-86f0-690f08d31711",
  "status": "successful"
}

Delete Notification Rule Step Request

Delete Notification Rule Step request is used to delete the notification rule step in OpsGenie.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameID or username of the user that the rule belongs to. Either of them should be specified.
ruleIdId of the rule step will be deleted.
idId of the rule step will be deleted.

Sample Request

curl -XDELETE 'https://api.opsgenie.com/v1/json/user/notificationRule/step?apiKey=ba503523-f94c-4adb-a2f4-376e99f68885&[email protected]&ruleId=5ef5cc7f-23f4-4168-9f0f-d543d0c325b4&id=2dae31b1-5e89-4c33-a05f-d1f0e746c4db'

Response:

{
  "code": 200,
  "status": "successful"
}

Enable Notification Rule Step Request

Enable Notification Rule Step request is used to enable notification rule step in OpsGenie.

It takes the following parameters:

Mandatory Parameters

Parameter
apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
ruleIdId of the notification rule that step belongs to.
idId of the rule step will be enabled.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/step/enable?apiKey=eb243592-faa2-4ba2-a551q-1afdf565c889' -d '
{
    "username":"[email protected]",
    "ruleId":"d609c2d4-c7e0-4c3c-b339-40bb58f89963",
    "id":"bd96aa09-e161-4c7e-8d15-ba5e55b7b1e2"
}'

Response:

{
  "status": "success"
}

Disable Notification Rule Step Request

Disable Notification Rule Step request is used to disable notification rule step in OpsGenie.

It takes the following parameters:

Mandatory Parameters

apiKeyAPI key is used for authenticating API requests
userId / usernameId or username of the user that the rule belongs to. Either of them should be specified.
ruleIdId of the notification rule that step belongs to.
idId of the rule step will be disabled.

Sample Request

curl -XPOST 'https://api.opsgenie.com/v1/json/user/notificationRule/step/disable?apiKey=eb243592-faa2-4ba2-a551q-1afdf565c889' -d '
{
    "username":"[email protected]",
    "ruleId":"d609c2d4-c7e0-4c3c-b339-40bb58f89963",
    "id":"bd96aa09-e161-4c7e-8d15-ba5e55b7b1e2"
}'

Response:

{
  "status": "success"
}