I’ve been working with the Hubspot API and managed to create a PHP script that lists companies and their file attachments. Now I want to take it a step further and download these attachments. But I can’t find an API endpoint for this. Any ideas?
I know the metadata from GET /filemanager/api/v2/files includes the URL of hosted files, like this:
I’ve dealt with this exact problem in my work. The key is using the ‘signed_url’ field as Bob mentioned, but there’s a bit more to it. These URLs are time-sensitive and expire quickly, so you’ll need to generate a fresh one each time you want to download a file.
In your PHP script, after you get the file metadata, make another API call to ‘/filemanager/api/v2/files/{fileId}’ to fetch the current signed URL. Then use that URL to download the file. Remember to handle potential errors, as the download might fail if the URL expires mid-process.
Also, be mindful of rate limits. If you’re downloading many files, you might want to implement a delay between requests to avoid hitting Hubspot’s API limits. It’s a bit of extra work, but it’s reliable once set up correctly.
hey joec, i ran into the same issue. turns out you need to use the ‘signed_url’ field instead of the regular ‘url’. it’s in the same response from the api. that signed url will let you download the file directly. hope this helps!