APIs & Integrations

hilton22
Contributor | Diamond Partner
Contributor | Diamond Partner

Association deal - contact on Create Deal method V3

SOLVE

Hi all,

 

I'm tring to create a new deal, associated with a existing contact, via API using V3 documentation. But I can't find, in the V3 doc, a way to associate this new deal with the contact, at the moment of deal creation.

I recall that in V2 method, you have two indexes ("associations" and "properties"), where you can create and simultaneously, associate with one or more contacts.

 

Is that possible in the V3 API?

 

Thanks,

0 Upvotes
1 Accepted solution
Willson
Solution
HubSpot Employee
HubSpot Employee

Association deal - contact on Create Deal method V3

SOLVE

Hi @hilton22 

 

The new process for creating new object records and associations to another object record must be handled in a 2-step process.

 

In this case, the record must initially be created, see below:

https://api.hubapi.com/crm/v3/objects/deals?limit=10&archived=false&hapikey=YOUR_HUBSPOT_API_KEY

Once created, we now use the Id generated in the response to add the association via the following request:

Example PUT URL:
https://api.hubapi.com/crm-associations/v1/associations?hapikey=demo

Example PUT JSON:
{
  "fromObjectId": 496346,
  "toObjectId": 176602,
  "category": "HUBSPOT_DEFINED",
  "definitionId": 15
}

The definition Id can be found here in our Definitions Table: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview

 

To note, Associations are defined based on the type of objects being associated, and the direction of that association. Association definitions are unidirectional, so you'll use a different definition ID depending on which object type you're starting with. 

 

I hope this helps!

Product Manager @ HubSpot

View solution in original post

0 Upvotes
8 Replies 8
Willson
Solution
HubSpot Employee
HubSpot Employee

Association deal - contact on Create Deal method V3

SOLVE

Hi @hilton22 

 

The new process for creating new object records and associations to another object record must be handled in a 2-step process.

 

In this case, the record must initially be created, see below:

https://api.hubapi.com/crm/v3/objects/deals?limit=10&archived=false&hapikey=YOUR_HUBSPOT_API_KEY

Once created, we now use the Id generated in the response to add the association via the following request:

Example PUT URL:
https://api.hubapi.com/crm-associations/v1/associations?hapikey=demo

Example PUT JSON:
{
  "fromObjectId": 496346,
  "toObjectId": 176602,
  "category": "HUBSPOT_DEFINED",
  "definitionId": 15
}

The definition Id can be found here in our Definitions Table: https://developers.hubspot.com/docs/methods/crm-associations/crm-associations-overview

 

To note, Associations are defined based on the type of objects being associated, and the direction of that association. Association definitions are unidirectional, so you'll use a different definition ID depending on which object type you're starting with. 

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
HemanthKotha
Member

Association deal - contact on Create Deal method V3

SOLVE

Yeah, this is possible now. For example, have a look at the post from one of the Community members.

https://community.hubspot.com/t5/APIs-Integrations/Is-it-possible-to-associate-a-record-with-a-custo... 

0 Upvotes
hilton22
Contributor | Diamond Partner
Contributor | Diamond Partner

Association deal - contact on Create Deal method V3

SOLVE

Hi @Willson,

 

Thanks for the reply. I figured out that 2-step process is the only way, according to the new API documentation.

 

But I don't think that is the best solution. Create a deal using the V2 documentation works fine... you can create a deal and at the same time, associate it with a contact, decreasing the numbers of requests made by a external application.

 

I realy don't understand why Hubspot is making this decision. For me this is a step-back move... Hubspot has a request limit per day/seconds... I believe this new version of Hubspot API's suppose to help developers decrease the numbers of requests... but instead, is increasing those numbers... I realy don't get it!

 

Any way... thanks for the answer!

 

Cheers, 

Jebble
Member

Association deal - contact on Create Deal method V3

SOLVE

It seems your documentation is updated again, so now it does take a single call with `properties` and `associations` again. But now this documentation is (in case of PHP) for the api-client v10, which is in beta, and there is no documentation to be found for v9...

So funny thing is, the v10 documentation works in v9, except the typehinting isn't supporting it, meaning that PHPStan or similar tools are crying that we're sending the wrong object..

0 Upvotes
matheusleitao
Participant

Association deal - contact on Create Deal method V3

SOLVE

Had do register just to comment, it is incredible how a company as big as hubspot couldn't achiteture it so it would receive only one request.. . Well, it does make me feel a little assured, i can look at my code and don't feel as bad as i should ‌😂

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

Association deal - contact on Create Deal method V3

SOLVE

Hey @hilton22 

 

I just wanted to say thanks for this feedback, I have forwarded this internally now to ensure we capture any and all feedback in this area!

 

I'll mark this one as solved but let me know if you have any follow-up.


Thanks

Product Manager @ HubSpot
0 Upvotes
DDSBA
Member

Association deal - contact on Create Deal method V3

SOLVE

Hello,

 

Like @hilton22 stated, the ability to associate a an object with another upon its creation, in my case I want to associate a company with a deal when I create the company, is important to my business. Is there an update to this feature?

DDSBA
Member

Association deal - contact on Create Deal method V3

SOLVE

Or is there any way to create a deal and associate the object in one step?