Skip to main content

I’m trying to retrieve all the incidents for certain days. I’m using what I think is the correct syntax from the docs:

 

curl -s --request GET "https://api.pagerduty.com/incidents?since=2025-06-29T00:00:00Z&until=2025-06-29T23:59:59Z&limit=100" \
  --header 'Accept: application/json' \
  --header 'Authorization: Token token=REDACT' \
  --header 'Content-Type: application/json' -o /tmp/pdalerts_test.json
 

However, the results I get only show six results when I can see many more in the Pager Duty website. 

Depending on the day, sometimes I get more, sometimes I get less, so I don’t believe that I’m hitting a paging limit?

Anyone have a hint?

Ah, looks like I was foiled by time zones----however, is there a list of examples on how the time zone should be formatted in the query?

 

 


Hi ​@big.dan.dobbs,

The API expects ISO 8601 timestamps, and by default, the Z at the end means UTC. If your incidents are created in a different time zone, you’ll want to adjust your since and until parameters accordingly. Here’s the API doc stating the DateTime type.

Here are some examples:

  • UTC: 2025-06-29T00:00:00Z
  • Pacific Time (PDT): 2025-06-29T00:00:00-07:00
  • Eastern Time (EDT): 2025-06-29T00:00:00-04:00
  • Central European Summer Time (CEST): 2025-06-29T00:00:00+02:00

So, if you want to pull all incidents for June 29th in Pacific Time, your query would look like:

https://api.pagerduty.com/incidents?since=2025-06-29T00:00:00-07:00&until=2025-06-29T23:59:59-07:00&limit=100  

Also, double-check the API response for the more field, if it’s true, you’ll need to paginate to get all results.

Hope this helps! Let me know if I can help with anything else, and have a nice day!


@lupimiguel I believe I asked the question incorrectly. :D

 

The formatting was fine, it’s just that everything (from where I was sitting) was seven hours off because of the time zone----so I had to add the ‘time_zone’ to my query. However, there were no examples, so I wasn’t sure exactly which flavor they wanted. 

After some experimentation, I came up with this:

zone="America/Los_Angeles"
day=10
month=$(date +%m)
year=2025


curl -s --request GET "https://api.pagerduty.com/incidents?time_zone=${zone}&since=${year}-${month}-${day}T00:00:00Z&until=${year}-${month}-${day}T23:59:59Z&limit=100" \
--header 'Accept: application/json' --header 'Authorization: Token token=MYTOKEN' \
--header 'Content-Type: application/json' -o /tmp/pdalerts_${day}.json


This seems to be pulling things to me correctly, relative to my time zone. ​​​​​


Hi ​@big.dan.dobbs,

I didn’t get it either at first 😂

It should be a IANA timezone ID going into the time_zone parameter.

I’ll look over the docs if this needs to be made more clearer, as I’ve also had some trouble finding it through the examples.

Enjoy your weekend!


Reply