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.

EventProfileZendesk 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.

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/token:6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv -X DELETE

Python request

import requests

profile_id = '01E1G0NJSQPNPZRV096JXKXFAA'
api_token = '6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv'
url = f'https://coolbikes.zendesk.com/api/v2/user_profiles/{profile_id}'credentials = '[email protected]/token', api_tokenresponse = 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