There's a new version of the HubSpot API

As of November 30, 2022, HubSpot API keys are no longer a supported authentication method for accessing HubSpot APIs. Instead, you should use a private app access token or OAuth to authenticate API calls. Learn more about this change and how to migrate an API key integration to use a private app instead.

Upload a new file

Last updated May 15, 2023

POST /filemanager/api/v3/files/upload

Method Details

HTTP Methods:

POST

Content Type:

multipart/form-data

Response Format:

json

Requires Authentication?

Yes

Rate Limited?

Yes

Headers

User-Agent

Products:

Marketing & CRM

Required Scope:

files

Upload a new file to the file manager. This endpoint uses multi-part form encoding, rather than JSON.

On success, the response will include the metadata for the file.  See this page for an example.

Required Parameters How to use Description
OAuth access token or private app access token Authorization: Bearer {token} header Used to authenticate the request. Please see this page for more details about authentication.

Allowed Fields in the body

Parameter name Type Description
fileName string Optional field. Desired name of the file. If not provided the name will be inferred from the file data.
file File data The multi-part form encoded file to upload.
folderPath string Partially optional field. One of folderPath or folderId must be specified. Path of the folder the file should be uploaded into. Uploading files into the root path “/” is highly discouraged.
folderId string Partially optional field. One of folderId or folderPath must be specified. Id of the folder the file should be uploaded into.
charsetHunch string Optional field. The character set of the provided file.
options JSON string Required field. JSON string representation of the options object. See below.

options object

Field name Description
access
(enum)
Required field. Options are:

PUBLIC_INDEXABLE
The file will be publicly accessible by anyone who has the file url. Search engines will be able to index the file.

PUBLIC_NOT_INDEXABLE
The file will be publicly accessible by anyone who has the file url. The X-Robots-Tag: noindex header will be sent whenever the file is retreived, instructing search engines not to index the file.

PRIVATE
The file will be private and requires a signed url to access. Search engines will NOT be able to index the file.
ttl
(string)
Time to live. This is an optional field. If specified, the file will be permanently deleted after the specified amount of time. After deletion, the file cannot be recovered or restored.

The formats represent periods. For example “P3M” means a period of 3 months. The file will be deleted after 3 months. The limit for ttl is 1 year.
overwrite
(boolean)
If true this file with replace any existing files with the name name, folder, and type.

Note: If this is set to false, and the uploaded file matches the filename of an existing file in the same folder, the file will be uploaded with a number incremented filename (e.g. example_file.txt will become example_file-1.txt)
duplicateValidationStrategy
(enum)
Optional field. Options are:

REJECT
If a duplicate file is found, the upload request is rejected.

RETURN_EXISTING
If a duplicate file is found, the upload is cancelled and the existing file is returned instead.

NONE
No duplicate file validation is performed.

Defaults to NONE if not specified
duplicateValidationScope
(enum)
Optional field. Options are:

ENTIRE_PORTAL
Checks all files for a duplicate.

EXACT_FOLDER
Checks only the provided folder for a duplicate.

Defaults to EXACT_FOLDER if not specified