Recent searches
No recent searches
Is there a way to actually *delete* existing attachments on ticket comments based on a search?
Posted Jan 07, 2025
By delete, I mean delete, not “redact”. I mean using the API to run a search that has “has_attachment:true” included as part of its its query, then perform an action on the results such that if you were to subsequently run that same search with the same parameters, it would not return those results any longer, because you had deleted all of the attachments that were attached? I've been asked to write a script to automatically remove attachments on old, closed cases (as a retention policy - but not delete the tickets), and given the existence of the "DELETE /api/v2/uploads/{token}" endpoint, I had assumed this would be easy enough, until I actually got to that point, and realized that the {token} referenced by that api call is not the same as the attachment's id, and if I'm understanding correctly, may only be available if your script had itself just uploaded the attachment? Is there any way to get that token for an existing attachment, or any other way to delete (again, not “replace with an empty text file” - actually delete) an attachment given that you know the ticket id, comment id and attachment id you want to delete programmatically?
Or, I suppose, equally valid - is there any way (I doubt it?) to implement a query that would return tickets that had any attachments, unless all of its attachments had been redacted? As iterating through every ticket in our entire zendesk nightly and then just ignoring tickets we'd already processed (but still always returning all of them from the search results forever), doesn't seem like it would be a great idea, scaling-wise…or would that actually be the recommended approach?
Thanks
edit: I realized I could just stick a min as well as max date on the initial search filter, so it would at least only have to filter out a week's worth of already-redacted tickets after the fact, not every ticket every time. That is probably the best option at the moment, so I'm going to implement that. Leaving this here for the benefit of future Google searchers looking to implement something similar.
0
0 comments