La fonction de suggestion automatique permet d'affiner rapidement votre recherche en suggérant des correspondances possibles au fur et à mesure de la frappe.
Contributeur de premier rang | Partenaire solutions Diamond
How can I delete attachment from contact via API?
Hi Everyone,
I work for a HubSpot Diamond Partner. We have developed an app for the marketplace that aims to solve the issue of bulk deleting attachments. Our app allows users to access a CRM card showing all the attachments associated with an object record and easily delete them in bulk.
We are seeking beta testers who can try our app at no cost, provide valuable feedback, and assist us in enhancing the overall usability of the product.
Attachments are stored within engagements. So in order to delete an attachment, you must delete the engagement that it goes along with, which could be a note, task, email, or logged call. If you do not know the engagement ID we will need to do a few steps.
//Example https call: Note that "9" is the id for contact to engagement
https://api.hubapi.com/crm-associations/v1/associations/{Contact_ID}/HUBSPOT_DEFINED/9?hapikey=demo
//Example Response:
{
"results": [
13615120897,
13615494311,
14199337320
],
"hasMore": false,
"offset": 14199337320
}
Then once you have the engagement IDs you can iterate through them calling the Get an engagement endpoint. In the response, you will see details about the engagement including a key called "attachments" which will have a value of an array of associated file IDs. From this response, you should be able to determine which of those returned IDs is the one you wish to delete.
To update the engagement to have no attached files.
Another note is that within the attachment key from the get engagement endpoint is the file ID of the attachment, so you could also call the Delete a file by ID endpoint.
✔️ Was I able to help answer your question? Help the community by marking it as a solution.