Notification Rule Step API
If using the EU instance of Opsgenie, the URL needs to be https://api.eu.opsgenie.com for requests to be successful.
General Information
Create an API Integration and obtain your apiKey to make requests listed above. Please make sure that the integration is not restricted to access configurations.
You can refer Notification Settings for detailed information about the notification rules and their steps.
Create Notification Rule Step
Create Notification Rule Step request is used to add steps to notification rules in Opsgenie and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management
In-Line Parameters
Referred Name | Description |
---|---|
userIdentifier | Identifier of the user for the notification rule that step belongs to. You should provide either id or username of the user |
ruleId | Id of the notification rule that step belongs to |
JSON Body Fields
Fields | Mandatory | Description |
---|---|---|
contact | true | Defines the contact that notification will be sent to. contact parameter takes a contact object which is explained here with details. |
sendAfter | false | Time period (in minute) when notification will be sent after. Valid and Mandatory only for New Alert and Assigned Alert notification rules. sendAfter parameter should be given as an object which has a timeAmount field that takes amount as minutes. |
enabled | true | Specifies whether given step will be enabled or not when it is created |
Sample Request:
curl -X POST 'https://api.opsgenie.com/v2/4b26961a-a837-49d2-a1fe-0973013e3c3b/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
--header 'Content-Type: application/json'
--data
'{
"contact": {
"method": "email",
"to": "[email protected]"
},
"sendAfter": {
"timeAmount": 5
},
"enabled" : true
}
Response:
{
"result": "Created",
"data": {
"id": "dbf70781-d6d8-4924-b90d-6a0c77833748"
},
"took": 0.318,
"requestId": "b492b481-16b1-47e5-b8fe-a99ac3989fc3"
}
Get Notification Rule Step
Get Notification Rule Step request is used to retrieve notification rule step details of users in Opsgenie. It takes the following parameters:
In-Line Parameters
Referred Name | Description |
---|---|
userIdentifier | Identifier of the user for the notification rule that step belongs to. You should provide either id or username of the user. |
ruleId | Id of the notification rule that step belongs to |
stepId | Id of the notification rule step |
Sample Request:
curl -X GET 'https://api.opsgenie.com/v2/users/[email protected]/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps/dbf70781-d6d8-4924-b90d-6a0c77833748'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
Response:
{
"data": {
"_parent": {
"id": "e3face00-e378-4eb1-8141-cd21103d1814",
"name": "Create Alert Notification Rule"
},
"id": "dbf70781-d6d8-4924-b90d-6a0c77833748",
"sendAfter": {
"timeAmount": 5,
"timeUnit": "minutes"
},
"contact": {
"method": "email",
"to": "[email protected]"
},
"enabled": true
},
"took": 0.171,
"requestId": "ea3817f7-d450-4439-8ca7-50a229152ed4"
}
Update Notification Rule Step (Partial)
Update Notification Rule Step request is used to update steps of notification rules in partial manner and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management
In-Line Parameters
Referred Name | Description |
---|---|
userIdentifier | Identifier of the user for the notification rule that step belongs to. You should provide either id or username of the user |
ruleId | Id of the notification rule that step belongs to |
stepId | Id of the notification rule step |
JSON Body Fields
Fields | Mandatory | Description |
---|---|---|
contact | false | Defines the contact that notification will be sent to. contact parameter takes a contact object which is explained here |
sendAfter | false | Time period (in minute) when notification will be sent after. Valid and Mandatory only for New Alert and Assigned Alert notification rules. sendAfter parameter should be given as an object which has a timeAmount field that takes amount as minutes. |
enabled | false | Specifies whether given step will be enabled or not when it is created |
Sample Request:
curl -X PATCH 'https://api.opsgenie.com/v2/4b26961a-a837-49d2-a1fe-0973013e3c3b/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps/dbf70781-d6d8-4924-b90d-6a0c77833748'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
--header 'Content-Type: application/json'
--data
'{
"contact": {
"method": "email",
"to": "[email protected]"
},
"sendAfter": {
"timeAmount": 5
}
}'
Response:
{
"result": "Updated",
"data": {
"id": "dbf70781-d6d8-4924-b90d-6a0c77833748"
},
"took": 0.862,
"requestId": "becc8734-1911-44c7-8f54-ef2c2d7eb75b"
}
Delete Notification Rule Step
Delete Notification Rule Step request is used to delete the notification rule step and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management
In-Line Parameters
Referred Name | Description |
---|---|
userIdentifier | Identifier of the user for the notification rule that step belongs to. You should provide either id or username of the user |
ruleId | Id of the notification rule that step belongs to |
stepId | Id of the notification rule step |
Sample Request:
curl -X DELETE 'https://api.opsgenie.com/v2/users/[email protected]/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps/dbf70781-d6d8-4924-b90d-6a0c77833748'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
Response:
{
"result": "Deleted",
"took": 0.792,
"requestId": "be9a183f-97bb-413c-815e-c96f6e578a99"
}
List Notification Rule Step
List Notification Rule Steps request is used to retrieve all notification rule steps with details of users in Opsgenie. It takes the following parameters:
In-Line Parameters
Referred Name | Description |
---|---|
userIdentifier | Identifier of the user for the notification rule that step belongs to. You should provide either id or username of the user |
ruleId | Id of the notification rule that step belongs to |
Sample Request:
curl -X GET 'https://api.opsgenie.com/v2/users/[email protected]/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
Response:
{
"data": [
{
"_parent": {
"id": "e3face00-e378-4eb1-8141-cd21103d1814",
"name": "Create Alert Notification Rule"
},
"id": "99b06ef6-2a26-4232-938f-d53d91b086d3",
"sendAfter": {
"timeAmount": 1,
"timeUnit": "minutes"
},
"contact": {
"method": "email",
"to": "[email protected]"
},
"enabled": true
},
{
"_parent": {
"id": "e3face00-e378-4eb1-8141-cd21103d1814",
"name": "Create Alert Notification Rule"
},
"id": "dbf70781-d6d8-4924-b90d-6a0c77833748",
"sendAfter": {
"timeAmount": 5,
"timeUnit": "minutes"
},
"contact": {
"method": "email",
"to": "[email protected]"
},
"enabled": false
},
{
"_parent": {
"id": "e3face00-e378-4eb1-8141-cd21103d1814",
"name": "Create Alert Notification Rule"
},
"id": "ce87d1c3-4a1d-42e4-a7f8-bf3e4cdf4796",
"sendAfter": {
"timeAmount": 15,
"timeUnit": "minutes"
},
"contact": {
"method": "email",
"to": "[email protected]"
},
"enabled": true
}
],
"took": 0.09,
"requestId": "cb961ddd-4361-420c-868c-2eaa02b3411a"
}
Enable Notification Rule Step
Enable Notification Rule Step request is used to enable notification rule step and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management
In-Line Parameters
Referred Name | Description |
---|---|
userIdentifier | Identifier of the user for the notification rule that step belongs to. You should provide either id or username of the user. |
ruleId | Id of the notification rule that step belongs to. |
stepId | Id of the notification rule step. |
Sample Request Using User Id:
curl -X POST 'https://api.opsgenie.com/v2/users/4b26961a-a837-49d2-a1fe-0973013e3c3b/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps/dbf70781-d6d8-4924-b90d-6a0c77833748/enable'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
curl -X POST 'https://api.opsgenie.com/v2/users/[email protected]/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps/dbf70781-d6d8-4924-b90d-6a0c77833748/enable'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
Response:
{
"result": "Enabled",
"data": {
"id": "dbf70781-d6d8-4924-b90d-6a0c77833748"
},
"took": 0.235,
"requestId": "8e7b5e13-f813-494c-8a39-e63990114c80"
}
Disable Notification Rule Step
Disable Notification Rule Step request is used to disable notification rule step and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management
In-Line Parameters
Referred Name | Description |
---|---|
userIdentifier | Identifier of the user for the notification rule that step belongs to. You should provide either id or username of the user. |
ruleId | Id of the notification rule that step belongs to. |
stepId | Id of the notification rule step. |
Sample Request:
curl -X POST 'https://api.opsgenie.com/v2/users/[email protected]/notification-rules/e3face00-e378-4eb1-8141-cd21103d1814/steps/dbf70781-d6d8-4924-b90d-6a0c77833748/disable'
--header 'Authorization: GenieKey 50b71849-6b09-46d8-bd7b-046b9d942eb4'
Response:
{
"result": "Disabled",
"data": {
"id": "dbf70781-d6d8-4924-b90d-6a0c77833748"
},
"took": 0.235,
"requestId": "8e7b5e13-f813-494c-8a39-e63990114c80"
}
Fields of Contact Object
JSON Body Fields
Field | Mandatory | Description |
---|---|---|
method | true | This parameter is the contact method of user and should be one of email , sms , voice or mobile |
to | true | Address of the contact notification will be sent to |
contact
field example:
{
"contact": {
"method":"voice",
"to":"1-9999999999"
}
}
Updated about 6 years ago