You can delete events stored in Zendesk by deleting the profile associated with the events.
Each event is associated with a profile, which in turn is associated with a Zendesk user.
Event ↔ Profile ↔ Zendesk user
As a result, you can delete events by deleting the profile associated with the events. Deleting a profile is the only way to delete events.
Topic covered in this article:
For information on storing events, see Tracking events.
This article includes cURL and Python examples. The Python examples use Python 3.6 or greater and the requests library.
Deleting events by profile
You can delete events by deleting a profile associated with the events:
DELETE /api/v2/user_profiles/{profile_id}
You can retrieve the profile id value by making a preliminary request for the profile using an identifier query or the Zendesk user id of the person associated with the profile. See Accessing profiles.
Example
Data
-
Profile id:
"01E1G0NJSQPNPZRV096JXKXFAA"
cURL request
curl "https://coolbikes.zendesk.com/api/v2/user_profiles/01E1G0NJSQPNPZRV096JXKXFAA" \
-v -u devs@coolbikes.com:t1retube5 -X DELETE
Python request
import requests
profile_id = '01E1G0NJSQPNPZRV096JXKXFAA'
url = f'https://coolbikes.zendesk.com/api/v2/user_profiles/{profile_id}'
credentials = 'devs@coolbikes.com', 't1retube5'
response = requests.delete(url, auth=credentials)
if response.status_code != 204:
print(f'{response.status_code}: {response.text}')
else:
print(response.json())
Response
Status 204 OK
4 Comments
It's not particularly helpful to have to delete an entire profile just to get rid of an event. We've already encountered situations where an event was added twice by accident or has a typo, etc. It would be helpful to have a way to delete these events by ID.
Hey Matthew,
Thanks for this feedback.
A DELETE method on our events endpoint is something that is under consideration.
I'd like to know a little more about how you'd like to use this method - is it something that will making building out and testing your integration easier? Or does your business have a need to remove events as part of the normal daily operations?
Appreciate the insights.
James
Hi James. We would only be using this for development and testing purposes, or to correct a problem that was inadvertently introduced into production. We wouldn't be using it for any specific business rules.
Thanks Matthew, appreciate the insight, this aligns with our understanding of the need.
Cheers,
James
Please sign in to leave a comment.