Imports are used to populate a HubSpot account with object data that can be used with the sales, marketing, and service tools.
POST
request to /crm/v3/imports
with a request body that specifies how to map the columns of your import file to the associated properties in HubSpot.
API imports are sent as form-data type requests, with the request body containing following fields:
Content-Type
header with a value of multipart/form-data
.
The screenshot below shows what your request might look like when using an application like Postman:
objectTypeId
for the object/activity and whether you want to UPSERT
(create and update), CREATE
, or UPDATE
records. For example, the field would look like this in your request: "importOperations": {"0-1": "CREATE"}
. If you don’t include this field, the default value used for the import is UPSERT
.MONTH_DAY_YEAR
, but you can also use DAY_MONTH_YEAR
or YEAR_MONTH_DAY
.true
. To set the contacts in the file as non-marketing, use the value false
.true
.CSV
. For Excel files, use a value of SPREADSHEET
.columnMappings
array required to map data from your import file to HubSpot data. Learn more about column mapping below.columnMappings
array, include an entry for each column in your import file, matching the column header order of your spreadsheet.
For each column, include the following fields:
objectTypeId
value of the object or activity to which the data belongs. Refer to this article for a full list of objectTypeId
values.propertyName
should be null
when the toColumnObjectTypeId
field is used.columnType
of ASSOCIATION_KEYS
. Learn more about setting up your import file for a same object association import.objectTypeId
of the object the common column property or association label belongs to. Include this field for the common column property in the file of the object the property does not belong to. For example, if you’re associating contacts and companies in two files with the contact property Email as the common column, include the toColumnObjectTypeId
for the Email column in the company file.associationTypeId
and associationCategory
. Include this field for the common column property in the file of the object the property does not belong to. For example, if you’re associating contacts and companies in two files with the contact property Email as the common column, include the foreignKeyType
for the Email column in the company file.associationIdentifierColumn
as true
for the Email column in the contact file.importId
which you can use to retrieve or cancel the import. Once completed, you can view the import in HubSpot, but imports completed via API will not be available as an option when filtering records by import in views, lists, reports, or workflows.
GET
request to /crm/v3/imports/
. To retrieve information for a specific import, make a GET
request to /crm/v3/imports/{importId}
.
When you retrieve imports, information will be returned including the import’s name, source, file format, language, date format, and column mappings. The import’s state
will also be returned, which can be any of the following:
STARTED
: HubSpot recognizes that the import exists, but the import hasn’t started processing yet.PROCESSING
: The import is actively being processed.DONE
: The import is complete. All the objects, activities, or associations have been updated or created.FAILED
: There was an error that was not detected when the import was started. The import was not completed.CANCELED
: User cancelled the export while it was in any of the STARTED
, PROCESSING
, or DEFERRED
states.DEFERRED
: The maximum number of imports (three) are processing at the same time. The import will start once one of the other imports finishes processing.POST
request to /crm/v3/imports/{importId}/cancel
.
GET
request to /crm/v3/imports/{importId}/errors
. Learn more about common import errors and how to resolve them.
For errors such as Incorrect number of columns, Unable to parse JSON or 404 text/html is not accepted:
columnMapping
entry for each column. The following criteria should be met:
fileName
field in your request JSON match, and that you’ve included the file extension in the fileName
field. For example, import_name.csv.Content-Type
with a value of multipart/form-data
.Content-Type
. This may occur if you’re using Postman or if it’s included in the header of your Python script. Remove the duplicate before completing the request.