HubSpot File XML
This XML format represents files in HubSpot, and their properties.
Tasks
Minimal XML Sample
<?xml version="1.0" encoding="utf-8"?>
<HubSpotFiles>
<HubSpotFile>
<LocalFilePath>C:\Users\john.smith\Documents\invoice.pdf</LocalFilePath>
</HubSpotFile>
</HubSpotFiles>
In each of the following sections most of the XML has been omitted to make the samples easier to read. The whole structure of the HubSpotFiles schema is used below as a reference of where fields should be in the object model.
HubSpotFile
The HubSpotFile
element represents an individual file to be uploaded to HubSpot. This element appears as a child of the HubSpotFiles
collection.
XML Field | Example | Field Type | Input | Description |
---|---|---|---|---|
LocalFilePath | C:\Users\john.smith\Documents\invoice.pdf | string | Required | The file you would like to upload to HubSpot. Relative paths are supported. |
HubSpotFolderPath | /invoices | string | Optional | The folder you would like to upload the file to on HubSpot. Defaults to the root folder if not specified. |
HubSpotFilename | invoice_100004217.pdf | string | Optional | The name you would like to give the file on HubSpot. Defaults to the name in the LocalFilePath if not specified. |
OverwriteExistingFile | true | bool | Optional | Set to true to allow existing files to be overwritten on HubSpot, or false to prevent this. Defaults to true. |
Access | PRIVATE | enum | Optional | Valid values: PUBLIC_INDEXABLE , PUBLIC_NOT_INDEXABLE , PRIVATE . Defaults to PRIVATE . |
Charset | UTF-8 | string | Optional | The charset used in the file. HubSpot will determine this automatically if not specified. |
<?xml version="1.0" encoding="utf-8"?>
<HubSpotFiles>
<HubSpotFile>
<LocalFilePath>C:\Users\john.smith\Documents\invoice.pdf</LocalFilePath>
<HubSpotFolderPath>/invoices</HubSpotFolderPath>
<HubSpotFilename>invoice_100004217.pdf</HubSpotFilename>
<OverwriteExistingFile>true</OverwriteExistingFile>
<Access>PRIVATE</Access>
<Charset>UTF-8</Charset>
</HubSpotFile>
</HubSpotFiles>
Complete XML Sample
This sample shows all data that can be provided via our HubSpot File XML format.
<?xml version="1.0" encoding="utf-8"?>
<HubSpotFiles>
<HubSpotFile>
<LocalFilePath>C:\Users\john.smith\Documents\invoice.pdf</LocalFilePath>
<HubSpotFolderPath>/invoices</HubSpotFolderPath>
<HubSpotFilename>invoice_100004217.pdf</HubSpotFilename>
<OverwriteExistingFile>true</OverwriteExistingFile>
<Access>PRIVATE</Access>
<Charset>UTF-8</Charset>
</HubSpotFile>
</HubSpotFiles>
Attaching Files to Other Objects
Certain types of object in HubSpot will allow you to attach files, such as the notes object. The steps below describe how to upload a file to HubSpot, and attach it to a note that is associated with a deal called 'Quote 89412'.
- Upload the file to HubSpot using the Import Files into HubSpot task.
- Retrieve the ID of the file from the success file of the Import Files into HubSpot task.
- Use the Import Objects into HubSpot task to associate a note with the deal, specifying the ID of the file in the
hs_attachment_ids
field. If you want to attach multiple files, you can do so by specifying each file ID separated by a semi-colon.
<?xml version="1.0" encoding="utf-8"?>
<HubSpotObjects ObjectType="deal">
<HubSpotObject>
<Key>dealname</Key>
<Properties>
<Property Name="dealname" Value="Quote 89412" />
</Properties>
<Associations ObjectType="note">
<Association>
<HubSpotObject>
<Properties>
<Property Name="hs_note_body" Value="File attachment" />
<Property Name="hs_attachment_ids" Value="107347882713" />
</Properties>
</HubSpotObject>
</Association>
</Associations>
</HubSpotObject>
</HubSpotObjects>