The files endpoints are used to get and manage data in your file manager .
POST
request to files/v3/files
with the following fields. While a specific folder ID is not required at upload, it’s recommend to upload files into a folder and not the root directory. Folder requirements at upload are subject to change in the future.
Field | Description |
---|---|
file | The file to upload (required). |
options | A JSON object that controls the file’s privacy and indexability, and contains two fields: access , which is required, and ttl , which specifies a time period after which the file will be automatically deleted.If you’re using the ttl field:
|
folderId | The ID of the folder that the file will be uploaded to. Either this field or folderPath must be provided in your request (but not both). |
folderPath | The path of the folder that the file will be uploaded to. Either this field or folderId must be provided in your request (but not both). |
fileName | The name of the file. If no name is specified, a name will be generated from the file’s content. |
charsetHunch | Character set encoding for the uploaded file. If not provided, it will be derived from the file. |
cat.png
/library/cat_archive
id
and parentFolderId
of the uploaded file, which you can use to retrieve the file via a GET request.
POST
request to files/v3/files/import-from-url/async
, you can review the upload status of the file.
To do so, use a GET
request to files/v3/files/import-from-url/async/tasks/{taskId}/status
.
After making this request, you will receive one of the following replies:
PENDING
: the file is in the queue to be uploaded. The import process has not yet started.PROCESSING
: the file is in the process of being uploaded.CANCELED
: the upload has been canceled and the file will not be uploaded. To import the file to your HubSpot account, you will need to upload the file again.COMPLETE
: the file has been uploaded to the files tool successfully. The uploaded file will appear in your files tool.GET
request to files/v3/files/{fileId}
. This will return the file with details such as name, height and width, encoding, the URL, and more.
For example, to retrieve the details of a file:
If a file is set to private, the returned URL will result in a 404 error. To get a viewable URL of the file, you can make a GET
request to /files/v3/files/{fileId}/signed-url
. When making this request, you can include property
parameters to return specific properties such as height and width.
DELETE
request to files/v3/files/{fileId}
. This will mark the file as deleted and make the content of the file inaccessible.
To permanently delete a file, make a DELETE
request to files/v3/files/{fileId}/gdpr-delete
. This will permanently delete the file’s content and metadata within 7 days.
If a file is not GDPR deleted, its contents will remain on HubSpot’s servers in a private state where no one can access it. To ensure file contents are fully deleted, use the GDPR delete functionality.
POST
request to files/v3/folders
. When making the request, you can include the below fields.
Field | Required | Description |
---|---|---|
name | Yes | Name of the folder you want to create. |
parentFolderId | No | To create the folder within an existing folder, include this field with the existing folder’s ID. parentFolderId and parentFolderPath cannot be set at the same time. |
parentFolderPath | No | To create the folder within an existing folder, include this field with the existing folder’s path. parentFolderId and parentFolderPath cannot be set at the same time. |
files_ui_hidden.read.
PUBLIC_INDEXABLE
: file is publicly accessible by anyone who has the URL. Search engines can index the file.PUBLIC_NOT_INDEXABLE
: file is publicly accessible by anyone who has the URL. The X-Robots-Tag: noindex header will be sent whenever the file is retrieved, instructing search engines not to index the file.PRIVATE
: file is not publicly accessible. Requires a signed URL to display content. Search engines cannot index the file.ENTIRE_PORTAL
: search for a duplicate file in the account.EXACT_FOLDER
: search for a duplicate file in the provided folder.NONE
: do not run any duplicate validation.REJECT
: reject the upload if a duplicate is found.RETURN_EXISTING
: if a duplicate file is found, do not upload a new file and return the found duplicate instead.duplicateValidationScope
, which affects how we search for a duplicate.duplicateValidationStrategy
, which dictates what happens if a duplicate is found.