associatedObjectType in /crm/v3/exports/export/async

Hi, I think my understanding of how this end point works is wrong
I am trying to get get a list of all deals, along with company name.

params = { "exportType": "VIEW", "exportName": "test", "format": "csv", "language": "EN", "objectType": "DEAL", "objectProperties": [ "dealname", "name" ], "associatedObjectType": "COMPANY"}

My understanding would be if I associated COMPANY with DEAL here, I would be able to grab ‘name’ in the objectProperties (to come from COMPANY), but I get an error saying to remove ‘name’. I have also tried interchanging ‘name’ with ‘company’ and ‘associatedCompanyId’ and a few other strings to get it.
It seems like only properties from DEAL are allowed, and the ones from COMPANY are not. Then what is the point of

associatedObjectType

in this case?
Thanks

error:
{
“status”: “error”,
“message”: “Please fix or remove these properties as they are not a part of the object: name”,
“correlationId”: “5e5c37fe-de91-4f76-bfd4-843f78e3b62d”,
“context”: {
“objectProperties”: [
“[dealname, name]”
]
},
“category”: “VALIDATION_ERROR”
}

Hi @kwa_mark :waving_hand:

That’s correct. In your case, only Deal properties are allowed to be specified in the objectProperties object key. As per the API documentation, "if you include an associated object, the export will [only] contain the associated record IDs of that object and the records’ primary display property value (e.g., name)". No other properties belonging to the relevant associated object record(s) can be returned.

If required, you then need to make subsequent API requests to retrieve additional information about the associated records of interest (e.g. Get a Batch of Companies or CRM Export Companies). In order to do this, you’ll need record IDs. In this case, these record IDs are supplied within the export API response. This behaviour is consistent with other HubSpot APIs.

I hope this proves useful. Please let me know if you have any follow-up questions.

Thanks @zach_threadint

So what is

associatedObjectType

doing? If the Properties are only pulling from

objectType

Hi @kwa_mark :waving_hand:

Specifying “associatedObjectType” allows you to retrieve IDs and primary display property values of records

(in your example, relating to Companies)

associated with the request’s primary object type

(in your example, Deals)

. For example, if I replicate your request

(minus the “name” property)

in one of my test HubSpot portals, the resulting “exported” data looks like this:

"Record ID","Deal Name","Create Date","Last Modified Date","Associated Company","Associated Company IDs"
"8897652461","Test Deal 1","2023-09-13 17:46","2023-09-13 17:46","test-company-2.com","8526275800"
"8899275475","Test Deal 2","2023-09-13 17:46","2023-09-13 17:46","Test Company 1;test-company-2.com","8471318470;8526275800"
"8899275477","Test Deal 3","2023-09-13 17:46","2023-09-19 23:48","Test Company 1","8471318470"

You can see that the resulting data includes all Deal records

(see columns ‘Record ID’, ‘Deal Name’, ‘Create Date’ and ‘Last Modified Date’)

, alongside their associated Company records

(see columns ‘Associated Company’ [i.e. company name] and ‘Associated Company IDs’)

. In the case where multiple Companies are associated with a single Deal, all associated Company records are returned

(semi-colon separated)

. Finally, if I needed additional data relating to those associated Company records, I would need to make additional API calls to retrieve it, as per my previous message.

I hope this proves useful. Please let me know if you have any follow-up questions.