APIs & Integrations

SDaniels7
Member

How to add contact and company to a deal

Hi there hubspot community, hope you're all doing well.

I have a deal created and I want to use the API to add contacts and company details to that deal.

I'm using the V3 API and I believe the "Associate a deal with another object" endpoint under deals is the right endpoint to use.

The endpoint type is a PUT and here it is:
https://api.hubapi.com/crm/v3/objects/deals/{dealid}/associations/{toObjectType}/{toObjectId}/{assoc... 

I understand the dealID part, but what do I have to put at the other parameters to add contacts and company details to a deal.

Thank you!


 

0 Upvotes
1 Reply 1
dennisedson
HubSpot Product Team
HubSpot Product Team

How to add contact and company to a deal

Hey @SDaniels7 

In your case the Deal is the fromObjectType and the contact or company is the toObjectType

Each type of association has a name and an id

You can check out all of those association types and ids by hitting the assocations api like this

Lets pretend I want to get the association type for contacts associated with a deal.  I would use this url:

https://api.hubapi.com/crm/v3/associations/deals/contacts/types

This will return

{
    "results": [
        {
            "id": "3",
            "name": "deal_to_contact"
        }
    ]
}

https://api.hubapi.com/crm/v3/objects/deals/%7BdealId%7D/associations/%7BtoObjectType%7D/%7BtoObject...

Knowing that, we can then fill in some blanks with your parameters

dealId = id of the deal

toObjectType = contacts

toObjectId = id of contact

associationType = deal_to_contact

 

I recommend reading up on the associations api here.

 

 

 

0 Upvotes