Ticket comments API: filter by public property | Community
Skip to main content

Ticket comments API: filter by public property

  • August 28, 2023
  • 3 replies
  • 0 views

Denis14

The API for retrieving comments doesn't allow to show only public comments. It will be nice to have such ability. Currently there may be gaps in the response of public comments because there may be some private ones in between that should be filtered out from the response.

3 replies

  • August 28, 2023

HI Denis,

You could use the "public" property of the comments in your script to filter out private comments. It might look something like this pseudo-code:

public_comments = []
for page in comments_request:
for comment in page:
if comment["public"] is True:
public_comments.append(comment)

 

 


Denis14
  • Author
  • August 29, 2023

Hi @charles32!

That's what I actually do right now. But it may be not a good in terms of UX. For example, there may be 20 comments returned: 3 are public and 17 are private. Hopefully it may be not visible for the end user (filtering doesn't break cursor pagination values) but could be confusing if the percentage of private comments is high


Dominika
  • January 22, 2025

This would actually make an amaizing feature request to be able to just

 

<zendesk_domain>/api/v2/tickets/<ticket>/comments.json?private=false

 

to exclude the private comments. same for public=false could be implemented with a really simple DB querry change…