APIs & Integrations

Sandberg
Member

How can I attach a file to contact via API?

Background:
We have have form that triggers a web hook on form submission.
The webhook generates a PDF file with contents from the form and uploads the file to the file manager.

So far so good.

Problem:
Now I want to attach that file to a user (attaching that file in Hubspots when viewing the user works fine). But I can’t figure out how to attach the file via API. I tried via the Update contacts API but that seem to only update properties and does not seem to handle attachments. I did manage to save the file URL as a property on the user but I would prefer an attachment.

Possible related to this issue: https://integrate.hubspot.com/t/attaching-file-to-company/ but I fail to see how that would help me get my file attached to the user.

How can I get the file attached to the user?

1 Reply 1
Dadams
HubSpot Employee
HubSpot Employee

How can I attach a file to contact via API?

@Sandberg files get attached to records through engagements. When creating an engagement, you can include the IDs of the files in the file manager in the attachments array in the data. See the example POST JSON here:

Create an Engagement | Engagements API

POST /engagements/v1/engagements - Create an engagement via the HubSpot API.