APIs & Integrations

Anonymous
Not applicable

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?

3 Replies 3
AJT
Contributor

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

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

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

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

Hey, @Anonymous 👋 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:

  • Bob Belcher
  • Bob has two file attachments as confirmed by the API response and screenshot CleanShot 2023-01-27 at 11.19.41.png

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

 





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




0 Upvotes
Anonymous
Not applicable

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

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?