I’ve been working with HubSpot’s API for a while now and have had good success. I built a Python script using a third-party HubSpot library that can fetch all contacts and their associated document attachments.
Now I want to take it one step further and actually pull down these document attachments to my local system. But I can’t seem to find the right API method for retrieving the actual files. Does anyone know the correct approach for this?
I’m aware that the response data from:
GET /filemanager/api/v3/files
contains the location where files are stored. Here’s what I see:
"format":"PDF", "modified":1456789012000,
"location":"http://cdn1.hubspot.net/hub/12345/document-987654321-pdf",
"revision":2, "size":2048
But when I try to access these file locations directly, I get permission denied errors.
Any help would be appreciated!
Yeah, this is a super common HubSpot issue. Those direct CDN URLs from the Files API won’t work - they’re protected and need authentication. Don’t try accessing the raw location URLs directly. Instead, grab the signed download URL. Here’s what works: take the file ID from your first response and hit /filemanager/api/v3/files/{fileId}/signed-url. You’ll get back a temporary URL that lets you download without any auth headaches. Once you’ve got that signed URL, just do a regular HTTP GET request to pull the file down. Heads up though - these URLs expire in a few hours, so use them right away.
for sure! just make sure you’re using the right headers. the download link needs your api key up there. try sending it with the get request and it should work out.
Had this exact problem six months ago building a document sync tool. HubSpot changed how file downloads work - you can’t use the old method anymore. Use the /files/v3/files/{fileId} endpoint and add download=true to your request. That’ll give you the actual file content instead of just metadata. Don’t forget your auth header with your private app token or API key. Heads up - file download rate limits are way stricter than regular API calls. I learned this the hard way. Add delays between requests if you’re grabbing multiple files. Also, some file types get compressed when stored, so check the content-encoding header.