Is there any way to get all files filter by attachment ids?

Hi,

Currently, we are developing an integration that needs to get all the associated files with the HubSpot object (Deal/Contact/Company) and send them to our server. But I couldn’t find any batch read endpoint for files that we can filter files by attachment ids.

With the current enpoints of files API

  • GET /files/v3/files/search will return all the files (no option to filter more than one file by file ids)
  • and GET /files/v3/files/{fileId} will return only one file.

So this means I have to make multiple API cals to get the all files attached to the deal if deal has more than one attachment.

I also tried this with hubspot search API but didn’t work.

Is there any solution for this?

Hey, @Anonymous :waving_hand: Have you tried using the Search API this way?

  • Request

    https://api.hubapi.com/crm/v3/objects/notes/search​
    {
     "filterGroups": [
     {
     "filters": [
     {
     "propertyName": "hs_attachment_ids",
     "operator": "HAS_PROPERTY"
     }
     ],
     "filters": [
     {
     "propertyName": "associations.contact",
     "operator": "EQ",
     "value": "901"
     }
     ]
     }
     ]
    }
    
  • Response

    {
     "total": 2,
     "results": [
     {
     "id": "30561996841",
     "properties": {
     "hs_createdate": "2023-01-27T17:49:19.810Z",
     "hs_lastmodifieddate": "2023-01-27T17:49:19.810Z",
     "hs_object_id": "30561996841"
     },
     "createdAt": "2023-01-27T17:49:19.810Z",
     "updatedAt": "2023-01-27T17:49:19.810Z",
     "archived": false
     },
     {
     "id": "30561998428",
     "properties": {
     "hs_createdate": "2023-01-27T17:49:48.590Z",
     "hs_lastmodifieddate": "2023-01-27T17:49:48.590Z",
     "hs_object_id": "30561998428"
     },
     "createdAt": "2023-01-27T17:49:48.590Z",
     "updatedAt": "2023-01-27T17:49:48.590Z",
     "archived": false
     }
     ]
    }
    

My example Contact:

I hope this helps get you moving in the right direction. I understand it’s likely not a 100% solution, and I wanted to share one approach I’ve found using these endpoints.

This uses the pseudo-association “associations.contact” for my test, but you can use “associations.deal” in the same manner.

Have fun building! — Jaycee

Hi @Jaycee_Lewis ,

Thanks for the answer. However that is not what I exactly want.

I want to get all file urls accached to hubspot deal.

For example if I use files API:

GET /files/v3/files/{fileId} will return

Response :

{
 "id": "99267136826",
 "createdAt": "2023-01-20T09:22:54.650Z",
 "updatedAt": "2023-01-25T07:29:37.134Z",
 "archived": false,
 "name": "icon-sync-active",
 "path": "icon-sync-active.svg",
 "size": 639,
 "height": 25,
 "width": 25,
 "encoding": "svg",
 "type": "IMG",
 "extension": "svg",
 "defaultHostingUrl": "https://5641059.fs1.hubspotusercontent-na1.net/hubfs/5641059/icon-sync-active.svg",
 "url": "https://5641059.fs1.hubspotusercontent-na1.net/hubfs/5341159/icon-sync-active.svg",
 "isUsableInContent": true,
 "access": "PUBLIC"
}

Here I want to get the url value of all the attachemnts of hubspot object. But I couldn’t find any batch read end point to get all files filter by file ids or all attachments urls associated with hubspot object(DEAL/CONTACT/COMPANY).

Currently I have to use multiple API calls to do this.

Is there any way to do this with a single API call?

It would be nice if there was a batch read function (By attachment ids) for files. Please create this!