Cannot delete engagements for contacts via API

I’m using Python and I am attempting to delete all notes/engagements for a contact before re-uploading some new notes for the same contact. I can get the notes for a contact but when I attempt to delete the engagements, I get a 204, but it never deletes the engagements within Hubspot.

Here’s my code:

def delete_all_contact_notes(self, contact_id): url = f'https://api.hubapi.com/engagements/v1/engagements/associated/CONTACT/{contact_id}/paged' response = requests.get(url, headers=self.get_headers()) if response.status_code == 200: notes = response.json()['results'] for note in notes: self.delete_note(note['engagement']['id']) else: print("Failed to retrieve contact notes.") return Nonedef delete_note(self, note_id): url = f"https://api.hubapi.com/engagements/v1/engagements/{note_id}" response = requests.delete(url, headers=self.get_headers()) if response.status_code == 204: print(response.text) print(f"Note with ID {note_id} deleted successfully.") else: print(f"Failed to delete note with ID {note_id}. Error: {response.text}")

I’ve also tried just using a curl command outside of my script:

curl -X DELETE -H "Authorization: Bearer <token>" 'https://api.hubapi.com/engagements/v1/engagements/xxxxxxxxx'

I don’t get a response back, but nothing is deleted.

Any ideas?

Hi @KBrunette,
Thank you for asking the Community!
I understand that you’d like to bulk delete notes (engagements) for contacts via API.
I found this similar post that might help you: “Quick/simple way to delete all Contact Notes for all Contacts?”.
I also wanted to invite a couple of subject matter experts to this conversation: Hi @ChrisoKlepke, @himanshurauthan and @SkeeStylus do you have suggestions to help @KBrunette, please?
If anybody else has anything to add and/or share, please feel free to join in the conversation :slightly_smiling_face:
Thanks a lot and have a fantastic day!
Best,
Bérangère

Got it. Turns out my API call was indeed working, there were just so many of them. Had to update my code to loop through all of them.

def delete_all_contact_notes(self, contact_id): url = f'https://api.hubapi.com/engagements/v1/engagements/associated/contact/{contact_id}/paged' offset = 0 limit = 100 # Adjust as needed has_more = True note_tracker = 0 print("Preparing to delete notes for: " + str(contact_id)) while has_more: params = { 'limit': limit, 'offset': offset } response = requests.get(url, headers=self.get_headers(), params=params) if response.status_code == 200: notes = response.json() print("\tFound: " + str(len(notes)) + " Notes for Hubspot Contact_id: " + str(contact_id)) for note in notes['results']: note_id = note['engagement']['id'] self.delete_note(note_id) note_tracker += 1 if notes['hasMore']: offset += limit else: has_more = False print("\tSuccessfully deleted: " + str(note_tracker) + " for Hubspot Contact ID: " + str(contact_id)) else: print("Failed to retrieve contact notes.") return None

Hi @KBrunette, I hope that you are well!
I am delighted to see that all is working for you now!
Also, thanks for sharing this with the Community, it will be useful for many other Community Members!
Have a great day and weekend!
Best,
Bérangère