How can I delete attachment from contact via API?


I am looking for deleting attachment from Hubspot contact via API but I can't find it. Can anyone show me how to do that?

2 Replies 2
Top Contributor | Platinum Partner

Hi @JZhao,


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.


First, by using the Get associations for a CRM object endpoint, we can grab all the engagement IDs associated with a Contact:




//Example https call: Note that "9" is the id for contact to engagement{Contact_ID}/HUBSPOT_DEFINED/9?hapikey=demo

//Example Response:
  "results": [
  "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.


Then you can call the DELETE an Engagement endpoint to delete the engagement. Another option is to call the Update an Engagement endpoint with a payload of:




 "attachments": [ ]



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.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk


Thanks for your response.


I also found this file API:


What is the different between file api and engagement API? when should I use each of them?