Inaccurate and Unpredictable values of "total" field in API responses

PagerDuty APIs when hit with total=true parameter should respond with the “total” field populated with the number of resources matching the query.

When I hit any such API, it returns some number as total. When I access more resources by changing offset, the value of total changes for every response.

Is my understanding of the “total” field incorrect or is there something strange about the APIs?

Hi Amit,

Thank you for the post!

The total refers to the total number of resources that match the passed parameters. If you include the offset parameter, then the total will reflect the offset results.

I hope that helps, please let us know if you have any other questions!

Hi Shirley,

Thanks for the response. I still don’t get it.

For instance, I hit the incidents API to list all incidents, and it says the total is 50 and returns the first 25 incidents (since default limit = 25)
The second time, I hit the API again with offset = 26 (assuming default limit=25). I expect the API to return the next 25 records and more = false. But I get more = true, implying more records exist and this time, the value of total has also changed.

I expect the total field to give me the total number of incidents.

Is my understanding here correct?

Hi Amit,

Thank you for the follow-up!

The issue you are experiencing may be caused by the offset parameter.

Using your example, the second request should have an offset value of 25.

I hope that helps, please let us know if you have any other questions.