APIs & Integrations

SDaniels7
Member

How to associate a deal with contact

Hi there hubspot community,

I'm trying to associate a deal with a contact, but cannot figure out what the parameters should be passed on the endpoint.

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... 

0 Upvotes
3 Replies 3
GBersac8
Participant

How to associate a deal with contact

How to find the {toObjectType} value?

0 Upvotes
ChehakWadhdwa
Member | Diamond Partner
Member | Diamond Partner

How to associate a deal with contact

hey @SDaniels7 

 

i have a function for you just pass the required arguments

in your case fromid=id of deal

toid= another object id which you want to associate 

fromObject=deal

toObject= another object 

 

function associateToOther(fromid,toid,type,fromObject,toObject)

  {

    

var options3 = { method: 'POST',

  url: 'https://api.hubapi.com/crm/v3/associations/'+fromObject+'/'+toObject+'/batch/create',

  qs: { hapikey: <HUBAPIKEY> },

  headers: 

  { 

    'Content-Type': 'application/json' },

  body: {

  "inputs": [

    {

      "from": {

        "id": fromid

      },

      "to": {

        "id": toid

      },

      "type": type

    }

  ]

},

  json: true };

           request(options3, function (error, response, body) {

                              if(response.statusCode==201)

                                 {

                                  //passenger associated to contact successfully

                                   console.log("Passenger associated to contact successfully");

                                   //now find the deal for passenger and associate contact to that deal

                                   if(toObject=="contact")

                                   searchDeal(toid);

                                 }

                                 

                              

                               }); 

  }

ChehakWadhdwa
Member | Diamond Partner
Member | Diamond Partner

How to associate a deal with contact

hi @SDaniels7 

if it helped you then mark it as Solution and help community.

0 Upvotes