Import file from URL and setting access as "private:

Hello,
I am a new hubspot dev; learning as I go… I am trying to upload a PDF as “private” via API; I can do it successfully but the acccess is set to “public_indexable” once it’s uploaded.
I thought it might be a folder setting issue so I set it to make all children private.
After many failed attempts, I decided to use the community tool to troubleshoot and noticed that in the tool the API also sets the parameters back to “public_indexable”.
There seems to be another issue with the tool where it doesn’t recognize values in all the parameters but the buggest issue I see is that the tool is showng me the same behavior I am seeing in my API call.

Is anyone else running into this?

Hello @JonathanVasquez
Thanks for the using this import file,

When uploading a file (like a PDF) via the HubSpot Files API, the access level defaults to public_indexable, even if the folder is set to private or you try to force a different access level. You must explicitly set the access type after upload using a separate call to change the file’s visibility.

The Files API behaves in two distinct stages:

1. File Upload – This step uploads your file, and it defaults to public_indexable access regardless of folder settings.

2. Patch/Update File Metadata – This is where you can change the visibility to private after upload.

Even if your folder is marked private, the file will still be public_indexable unless you update it explicitly.

How to Set a File to Private (Correct Way)
1. Upload the file using /files/v3/files

2. Capture the file ID from the response

3. Make a PATCH request to /files/v3/files/{fileId} to update access

1. Upload the PDF

POST https://api.hubapi.com/files/v3/files

Headers:
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: multipart/form-data

Body:
file: [your PDF file]
options: {
“access”: “private”,
“ttl”: “P3M” // optional
}

2. Update Access Type After Upload

PATCH https://api.hubapi.com/files/v3/files/123456789

Headers:
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

Body:
{
“access”: “private”
}
Why Folder Settings Don’t Help
The HubSpot folder system is organizational, not hierarchical like a traditional filesystem. Access is controlled per file, so even if you set a folder to private or “make all children private,” newly uploaded files will still default to public unless updated manually.

Using HubSpot’s File Upload Tool
You noticed the community tool or HubSpot UI tool resets the access back to public_indexable — this is a bug or limitation in that tool. It behaves like the API: upload defaults to public unless you override it.
The first step is upload file with ‘/files/v3/files’ this action and its required
The second step is set access to private with ‘PATCH /files/v3/files/{fileId}’ this action and its required
The Rely on folder privacy is does not work.

Hi @JonathanVasquez

HubSpot by default sets the PDF file type to public. What you can do here is make one more call to edit the file’s privacy. Update file API will do this for you.
You can also follow @Sapna1 instructions.

Thanks!

Hey, @JonathanVasquez :waving_hand: I did a quick read of the documentation and then did a simple test. I hope this helps.

My first suggestion, when testing endpoints, is to look into Postman. Our awesome DevRel team set up a HubSpot Postman collection that will make your testing life 1000% easier.

Here’s my test:

POST https://api.hubapi.com/files/v3/files/import-from-url/async

{
 "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
 "fileName": "testPDF1",
 "folderId": "92105487368",
 "access": "PRIVATE",
 "overwrite": true,
 "duplicateValidationStrategy": "NONE",
 "duplicateValidationScope": "ENTIRE_PORTAL",
 "expiresAt": "2025-09-24T18:19:34.793Z"
}
  • Result

Have fun testing! — Jaycee

Thank you all.
@Sapna1 @GRajput @Jaycee_Lewis
I had already implemented the “patch” approach before Jaycee replied; it works. Though I am curious as to why @Jaycee_Lewis sees a different result and I was able to reach the same result in Postman but not in the actual API integration.