Forwarding Rule 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.

Create Forwarding Rule

Create forwarding rule request is used to add new forwarding 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

JSON Body Fields

FieldsMandatoryDescriptionLimit
fromUsertrue The user object of user whose notifications will be forwarded. You can refer to here for more details of user object
toUsertrue The user object of user who will receive the forwarded notifications. You can refer to here for more details of user object
startDatetrue The date and time for forwarding will start, which takes a date format as (yyyy-MM-dd'T'HH:mm:ssZ) (e.g. 2017-01-15T08:00:00+02:00)
endDatetrue The date and time for forwarding will end, which takes a date format as (yyyy-MM-dd'T'HH:mm:ssZ) (e.g. 2017-01-15T08:00:00+02:00)
aliasfalseA user defined identifier for the forwarding rule. There can be only one forwarding rule with the same alias. Provides ability to assign a known id and later use this id to perform additional actions such as update the rule, etc.512 chars

Sample Request

curl -X POST 'https://api.opsgenie.com/v2/forwarding-rules'
    --header 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'
    --header 'Content-Type: application/json'
    --data
'{
    "fromUser" : {
        "id" : "ac8f4bf1-77ec-4a6d-9805-9c0a9c0d0d24"
    },
    "toUser" : {
        "id" : "a65c6b81-ffbf-41bd-b674-b06de5d90c26"
    },
    "alias" : "ruleAlias",
    "startDate" : "2017-07-05T08:00:00Z",
    "endDate" : "2017-07-06T18:00:00Z"
}'

Response:

{
    "data": {
        "alias": "ruleAlias",
        "id": "6667cb5b-a5ce-4550-9469-1dbcabac6ffb"
    },
    "took": 9.297,
    "requestId": "387dc75c-1138-4733-b5bd-5c9cce1ac715"
}

Get Forwarding Rule

Get forwarding rule request is used to search and retrieve forwarding rules in OpsGenie

In-Line Parameters

Referred NameDescription
identifierIdentifier of the forwarding rule

Query Parameters

ParameterMandatoryDescription
identifierTypefalseType of the identifier that is provided as an in-line parameter. Possible values are id and alias. Default value is id

Sample Request

curl -X GET 'https://api.opsgenie.com/v2/forwarding-rules/6667cb5b-a5ce-4550-9469-1dbcabac6ffb'
    --header 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'

Sample Request With identifierType

curl -X GET 'https://api.opsgenie.com/v2/forwarding-rules/ruleAlias?identifierType=alias'
    --header 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'

Response:

{
    "data": {
        "fromUser": {
            "id": "e58d6ee3-37bd-432f-9ded-64808b761ae0",
            "username": "[email protected]"
        },
        "toUser": {
            "id": "4b26961a-a837-49d2-a1fe-0973013e3c3b",
            "username": "[email protected]"
        },
        "startDate": "2017-07-05T08:00:00Z",
        "endDate": "2017-07-06T18:00:00Z",
        "alias": "ruleAlias",
        "id": "6667cb5b-a5ce-4550-9469-1dbcabac6ffb"
    },
    "took": 0.119,
    "requestId": "58688d8f-e4bd-402e-a25f-9999a774e0af"
}

Update Forwarding Rule

Update forwarding rule request is used to update forwarding rule 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 NameDescription
identifierIdentifier of the forwarding rule

Query Parameters

ParameterMandatoryDescription
identifierTypefalseType of the identifier that is provided as an in-line parameter. Possible values are id and alias. Default value is id

JSON Body Fields

FieldsMandatoryDescription
fromUsertrue The user object of user whose notifications will be forwarded. You can refer to here for more details of user object.
toUsertrue The user object of user who will receive the forwarded notifications. You can refer to here for more details of user object.
startDatetrue The date and time for forwarding will start, which takes a date format as (yyyy-MM-dd'T'HH:mm:ssZ) (e.g. 2017-01-15T08:00:00+02:00)
endDatetrue The date and time for forwarding will end, which takes a date format as (yyyy-MM-dd'T'HH:mm:ssZ) (e.g. 2017-01-15T08:00:00+02:00)

Sample Request

curl -X PUT 'https://api.opsgenie.com/v2/forwarding-rules/6667cb5b-a5ce-4550-9469-1dbcabac6ffb'
    --header 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'
    --header 'Content-Type: application/json'
    --data '
{
    "fromUser" : {
        "username" : "[email protected]"
    },
    "toUser" : {
        "username" : "[email protected]"
    },
    "startDate" : "2017-07-07T08:00:00Z",
    "endDate" : "2017-07-08T08:00:00Z"
}'

Response:

{
    "data": {
        "alias": "ruleAlias",
        "id": "6667cb5b-a5ce-4550-9469-1dbcabac6ffb"
    },
    "took": 3.375,
    "requestId": "a6fa2988-8023-47b5-94a5-84af6a657384"
}

Delete Forwarding Rule

Delete forwarding rule request is used to delete forwarding 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 NameDescription
identifierIdentifier of the forwarding rule

Query Parameters

ParameterMandatoryDescription
identifierTypefalseType of the identifier that is provided as an in-line parameter. Possible values are id and alias. Default value is id

Sample Request

curl -X DELETE 'https://api.opsgenie.com/v2/forwarding-rules/6667cb5b-a5ce-4550-9469-1dbcabac6ffb'
    --header 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'

Response:

{
    "result": "Deleted",
    "took": 1.208,
    "requestId": "7c02f0d9-c765-430f-90ef-a2d2465fdbe9"
}

List Forwarding Rules

List forwarding rules request is used to list forwarding rules in OpsGenie.

Sample Request

curl -X GET 'https://api.opsgenie.com/v2/forwarding-rules'
    --header 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'

Response:

{
    "data": [
        {
            "fromUser": {
                "id": "e58d6ee3-37bd-432f-9ded-64808b761ae0",
                "username": "[email protected]"
            },
            "toUser": {
                "id": "4b26961a-a837-49d2-a1fe-0973013e3c3b",
                "username": "[email protected]"
            },
            "startDate": "2017-05-08T21:00:00Z",
            "endDate": "2017-05-09T21:00:00Z",
            "alias": "",
            "id": "5c4694d5-37a4-4ada-99cc-0652296e9397"
        },
        {
            "fromUser": {
                "id": "e58d6ee3-37bd-432f-9ded-64808b761ae0",
                "username": "[email protected]"
            },
            "toUser": {
                "id": "4b26961a-a837-49d2-a1fe-0973013e3c3b",
                "username": "[email protected]"
            },
            "startDate": "2017-05-22T21:00:00Z",
            "endDate": "2017-05-24T21:00:00Z",
            "alias": "",
            "id": "e2a4ea3a-7abb-4bb9-8a05-00de82de544d"
        }
    ],
    "took": 0.212,
    "requestId": "cf4ad4dc-4dcd-4a0c-b50b-0cc5ea8f4091"
}

Fields of User Object

This object is used by fromUser and toUser fields. User object should have the following format:

FieldMandatoryDescription
idfalseThis parameter is the id of the user.
usernamefalseThis parameter is the username of the user.

🚧

One of id or username fields should be specified in user object.