How to set priority for existing incidents using API?

Hi,
I’m trying to find a way to set priority for existing incidents using API. But I can’t find method I should use to do it. Global Event rule is not the solution as we have integration per service.

Service-level event rules will be coming very soon, which seems like it may be a viable option for you, however, if you could give us an example privately by reaching out to support@pagerduty.com, we can help you determine whether this fits your use-case or explore other options.

Hello @Mazgajm,

Since it’s an existing incident, it should be possible through the REST API. (Automatic setting of priority on service-level integrations is what is not yet available per Tom’s comment above)

So, if the incident’s ID is known and the automation process that updates incidents has access via the REST API, then the incident can be set to a different priority using the Update an incident endpoint (PUT /incidents/{id}).

I gave it a try just now and was able to modify a triggered incident’s priority and urgency without changing the status or assignee.

Priority:

curl [header options redacted] https://api.pagerduty.com/incidents/PQ5S2OM -X PUT -d '{"incident":{"priority":{"id":"PP8TVAJ","type":"priority_reference"},"type":"incident"}}'

Urgency:

curl [header options redacted] https://api.pagerduty.com/incidents/PM1M43H -X PUT -d '{"incident":{"urgency": "high", "type":"incident"}}'

To get the list of priority references (with their IDs, necessary for setting incident priorities via the API), one can use the List priorities endpoint.

Hopefully that helps!

Cheers,

Thank you Thomas for your respond. Could you share more information regarding Service-level event rules, it will be useful for us in some other scenarios.

Hi Demitri, this is what I was looking for! Thank you for that. It is working very well using curl, but when I try to do the same from AWS Lambda or Postman, I’m getting: {“error”:{“message”:“Not Found”,“code”:2100}}. I’m passing the same header and payload as in curl, yet it’s not working as expected. Please check screen shots, did I missed something?

hello @Mazgajm,

I am not sure why you are getting that error. You should be able to update the priority using the payload below.

{
    "incident": {
    "type": "incident_reference",
        "priority": {
            "id": "P6J60K4",
            "type": "priority_reference",
            "summary": "P1"
    }
}
}

Please can you give it a go and let us know how you get along.

Cheers

@chiedu I’ve give it a try and got the same result, after some testing it seems that no matter what payload and auth token or from in header, I’m getting {“error”:{“message”:“Not Found”,“code”:2100}}. The incident ID is correct. This is very weird, as curl is working fine :confused:

Hi Michal,

Can you please try changing the call action from Post to Put and let us know if you continue to get this error?

1 Like

@Malcolm that was it, thank you! I didn’t noticed that I’ve used Post instead of Put :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.