Filtering Alerts for services - API endpoint for Alerts

Is there any API for fetching alerts similar to GET/services and GET/incidents. I tried GET/alerts endpoint and was able to get a response but I don’t see any documentation for the same in your API reference.

If you have an endpoint for alerts, I would like to know more about query parameters it supports for filtering. My end goal is to list the alerts for a service as shown in the GUI when you select a specific service.

Curl command I used for alerts

curl --location --request GET ‘
–header ‘Authorization: Token token=’
–header ‘Accept: application/vnd.pagerduty+json;version=2’
–header ‘Content-Type: application/json’

Response I got :
“alerts”: […
“limit”: 1,
“offset”: 0,
“more”: true,
“total”: 20567

Unfortunately, there isn’t a direct API. You will need go loop through incidents API and get related alerts for each incident.

I even did that but the alerts shown in the GUI for a service doesn’t match the alerts count I get from the incidents/:id/alerts. Any reason why this is happening. Also, this process of looping through incidents takes a lot of time.

There is an end point for /alerts(not documented any where in API docs) using which I can get all alerts for the account. Any simple way to filter them per services will be a great addition.

1 Like

This is pretty neat, did you come across the undocumented /alerts endpoint by pure chance?

I’ve been looking for a way to extract alerts-related data out via the API as well and it’d really help if PD officially supported it.

GUI supports /alerts end point so I tried to see if API can do the same and that’s how I found this end point.

If it’s not documented, it’s not a public, supported API endpoint. It may change at any time, use may break something, results not guaranteed, etc. so keep that in mind!