api v3 associations: are constants defined for "associationType"?

danhammari
Contributor

I have been searching through the API v3 documentation but have not been able to find a list of valid strings that would satisfy the associationType parameter in the HubSpot CRM objects API. In particular, I am using the endpoint below to associate a deal with a company:

 

https://developers.hubspot.com/docs/api/crm/deals

PUT /crm/v3/objects/deals/{dealId}/associations/{toObjectType}/{toObjectId}/{associationType}
 
The PHP library defines constants that satisfy the requirements for the toObjectType parameter:

namespace: HubSpot\Crm

    class: ObjectType

  example: \HubSpot\Crm\ObjectType::DEALS

 
However, I am unable to find any constants in the PHP library that may help with the associationType parameter. I can guess that the string I need will be something like "deal_to_company" but would rather not have to guess.
 
This is the PHP API that I am trying to implement:

namespace: HubSpot\Client\Crm\Deals\Api

    class: AssociationsApi

  method: create( $deal_id, $to_object_type, $to_object_id, $association_type, $paginate_associations = false );

 
Could anyone point me to where I can find an official list of standardarized values for the association types that API v3 expects?
PHP
0 Upvotes
2 Replies 2
dennisedson
Community Manager

Heyo @danhammari 

Throwing the usual cast of characters into this 😀

@quentin_lamamy , @philx , @AndrewFisher , @twnk , @ph_alti_trading any ideas? (and @ph_alti_trading , I know you are not using the v3 endpoints, but I like tagging you nonetheless 🙃)

Thanks,

Dennis



Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
ph_alti_trading
Participant

Hi @danhammari 

Looking at the page https://developers.hubspot.com/docs/api/crm/deals you provided, from the json response in the example the value "contact_to_company" is used. So yes, please go ahead and try "deal_to_company" 🙏

 

I don't think there is gonna be a list of standardarized values for the association types that API v3 expects, basically it's a "Discovery" like architecture.

In the case we can associate every object together, (Ref: https://github.com/HubSpot/hubspot-api-php/blob/master/lib/Crm/ObjectType.php) at the time of writing it would be 7 x 7 = 49 constants. In the previous version (Ref: https://github.com/HubSpot/hubspot-php/blob/master/src/Resources/CrmAssociations.php) there were already 46 constants. I think we can consider HubSpot drop the maintenance on such constants.

 

I can't tell you as I didn't test but looking at your previous ticket,in case the plural version is working ( 'deals_to_companies' ), you could might give a try with :
\HubSpot\Crm\ObjectType::DEALS . '_to_' . HubSpot\Crm\ObjectType::COMPANIES (or something similar)

If anyone has a feedback or opinion on the subject, you are welcome to share it the community 😃

 

Best of luck