Hi @MTan90,
Attachments (the functionality in your screenshot) are added using engagements (Calls, Emails, Notes, Tasks and Meetings). More information on this can be found here. Specifically:
“Use HubSpot’s files tool to manage and store files in HubSpot. Files hosted in HubSpot can be uploaded and used in both HubSpot and external content. They can also be attached to records using the engagements API.”
The approach we need to take is as follows:
1) Upload the file using Files API
We first upload the file to the Hubspot file manager. There are various parameters you can set to locate your file in an appropriate folder if you’d like. In any event on response you get a payload similar to the below, the most important attribute is the “id” which we can use when creating the engagement.
POST https://api.hubapi.com/files/v3/files
RESPONSE
{
"id": "76894753722",
"createdAt": "2023-08-16T09:17:11.805Z",
"updatedAt": "2023-08-16T09:17:11.805Z",
"archived": false,
"parentFolderId": "76538018526",
"name": "My API File-2",
"path": "/API uploads/My API File-2.png",
"size": 20659,
"height": 500,
"width": 500,
"encoding": "png",
"type": "IMG",
"extension": "png",
"defaultHostingUrl": "https://140281183.fs1.hubspotusercontent-eu1.net/hubfs/140281183/API%20uploads/My%20API%20File-2.png",
"url": "https://140281183.fs1.hubspotusercontent-eu1.net/hubfs/140281183/API%20uploads/My%20API%20File-2.png",
"isUsableInContent": true,
"access": "PUBLIC_NOT_INDEXABLE"
}
2) Create engagement using Engagement API and associate file
Using the ID returned in the successful response to the request above we can then create our engagement. Whether it’s a “Note, Email, Call, Task or Meeting” is entirely up to you. In my example I’ve opted to use a note to facilitate the attachment. See my request below:
POST https://api.hubapi.com/crm/v3/objects/notes
BODY
{
"properties": {
"hs_timestamp": "2023-08-16T10:30:00.000Z",
"hs_attachment_ids": "76894753722"
},
"associations": [
{
"to": {
"id": "101"
},
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 10
}
]
}
]
}
RESPONSE
{
"id": "19529202369",
"properties": {
"hs_attachment_ids": "76894753722",
"hs_createdate": "2023-08-16T09:24:15.453Z",
"hs_lastmodifieddate": "2023-08-16T09:24:15.453Z",
"hs_object_id": "19529202369",
"hs_object_source": "INTEGRATION",
"hs_object_source_id": "1914406",
"hs_timestamp": "2023-08-16T10:30:00Z"
},
"createdAt": "2023-08-16T09:24:15.453Z",
"updatedAt": "2023-08-16T09:24:15.453Z",
"archived": false
}
And the output in the CRM as shown below i.e Note on the record timeline and attachment populated:
In my case I created a note on a contact record. Depending on which record you’d like to create the engagement is up to you along with the type of engagement you wish to create. The process for attaching the file is the same regardless.