# Cannot delete engagements for contacts via API

**URL:** <https://community.hubspot.com/t/cannot-delete-engagements-for-contacts-via-api/104070>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [April 4, 2024, 3:03am UTC](https://community.hubspot.com/t/cannot-delete-engagements-for-contacts-via-api/104070 "2024-04-04T03:03:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KBrunette](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@KBrunette](https://community.hubspot.com/u/KBrunette)\
**Post date:** [April 4, 2024, 3:03am UTC](https://community.hubspot.com/t/cannot-delete-engagements-for-contacts-via-api/104070/1 "2024-04-04T03:03:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [April 5, 2024, 7:38am UTC](https://community.hubspot.com/t/cannot-delete-engagements-for-contacts-via-api/104070/2 "2024-04-05T07:38:40Z")

</div>

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?](https://community.hubspot.com/t5/APIs-Integrations/Quick-simple-way-to-delete-all-Contact-Notes-for-all-Contacts/m-p/673839)”.  
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 🙂  
Thanks a lot and have a fantastic day!  
Best,  
Bérangère

---

<div class="post-metadata">

**Author:** ![KBrunette](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@KBrunette](https://community.hubspot.com/u/KBrunette)\
**Post date:** [April 5, 2024, 1:09pm UTC](https://community.hubspot.com/t/cannot-delete-engagements-for-contacts-via-api/104070/3 "2024-04-05T13:09:13Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [May 10, 2024, 11:39am UTC](https://community.hubspot.com/t/cannot-delete-engagements-for-contacts-via-api/104070/4 "2024-05-10T11:39:22Z")

</div>

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
