Bootstrap FreeKB - OpsGenie - Create Alert using REST API
OpsGenie - Create Alert using REST API

Updated:   |  OpsGenie articles

Here is an example of how to submit a POST request to api.opsgenie.com using curl to create an alert.

~]$ curl --request POST https://api.opsgenie.com/v2/alerts --header 'Authorization: GenieKey 6760afa9-5a94-4b45-bd77-54752d4d5292' --header "Content-Type: application/json" --data '{"message":"My First Alert"}'

 

Which should return JSON that looks something like this.

{
 "result":"Request will be processed",
 "took":0.008,
 "requestId":"34762d72-a792-4719-83ee-eba0926d846c"
}

 

Here is a much more complete example, where every key other than the "message" key is optional.

curl 
--request POST https://api.opsgenie.com/v2/alerts 
--header 'Authorization: GenieKey 6760afa9-5a94-4b45-bd77-54752d4d5292' 
--header "Content-Type: application/json" 
--data 
'{
    "message": "My First Alert",
    "alias": "An Alias for My First Alert",
    "description":"This is my First Alert",
    "responders":[
        {"id":"c0905158-fa0e-4670-85ba-6e34971f6dd6", "type":"team"},
        {"name":"Acme", "type":"team"},
        {"id":"e8d06cb3-2461-430b-8ee7-4c1692ee81cf", "type":"user"},
        {"username":"john.doe", "type":"user"},
        {"id":"e8d06cb3-2461-430b-8ee7-4c1692ee81cf", "type":"escalation"},
        {"name":"Overnight Escalation", "type":"escalation"},
        {"id":"e8d06cb3-2461-430b-8ee7-4c1692ee81cf", "type":"schedule"},
        {"name":"Acme Team Schedule", "type":"schedule"}
    ],
    "visibleTo":[
        {"id":"c0905158-fa0e-4670-85ba-6e34971f6dd6", "type":"team"},
        {"name":"Acme", "type":"team"},
        {"id":"e8d06cb3-2461-430b-8ee7-4c1692ee81cf", "type":"user"},
        {"username":"john.doe", "type":"user"}
    ],
    "actions": ["Restart", "Example Action"],
    "tags": ["OverwriteQuietHours","Critical"],
    "details":{"foo":"Hello","bar":"World"},
    "entity":"An example entity",
    "priority":"P3"
}'

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a4e8fd in the box below so that we can be sure you are a human.