Sorting deleted tickets using cursor-based pagination not working | Community
Skip to main content

Sorting deleted tickets using cursor-based pagination not working

  • February 20, 2024
  • 4 replies
  • 0 views

I am using the `api/v2/deleted_tickets` endpoint, and using cursor-based pagination. I have noticed that the endpoint does not respect any type of sorting. I've tried providing `sort_by`, `sort_order`, and even `sort` query parameters, and the endpoint always returns the results in the same order. With offset-based pagination, the sort is respected. Can someone help with this?

4 replies

  • February 22, 2024

Hello @dylan14

I can see that this endpoint indeed uses cursor based pagination and you can use both "sort_by" and "sort_order" where the first allows values such as "id", "subject", or "deleted_at and the second "desc" and "asc".

I performed a test using the second one: https://z3nadvocate406.zendesk.com/api/v2/deleted_tickets?sort_order=asc


We can see the order is being changed as expected, is it not the case for you?


  • April 11, 2024

Hi there.  We are having exactly the same issue.  Your example didn't include the page[size] attribute, so I believe it's actually falling back to offset paging (as per https://developer.zendesk.com/api-reference/introduction/pagination/).

 

Your docs are pretty clear about using cursor pagination where possible, so it would be very good to be able to use sort_order/sort_by in conjunction with page[size].  For example, in our tests these both return the SAME result set:

 

https://xxx.zendesk.com/api/v2/deleted_tickets.json?sort_order=desc&sort_by=deleted_at&page[size]=2

 

https://xxx.zendesk.com/api/v2/deleted_tickets.json?sort_order=asc&sort_by=deleted_at&page[size]=2

 

Thank you

 

 


  • June 9, 2025

When using "cursor pagination", specifically when the URL contains page[size]=100, the sort parameter fails to perform sorting. This is a critical BUG.


Greg29
  • June 11, 2025

Hi zhangjian! Could you let me know specifically which endpoint and sort method your using when this issue arises?