How to create deal and associate contact in single request

Hello,

I am successfully creating deal via API, what I’m gonna do next is to associate contact to it.

Is there any endpoint I can use to process this two at once?

Thanks for your help.

Hi @rjhonnas

This will need to be two calls.

But maybe this is abstracted a bit and easier with one of the libraries :thinking:

@PCarlson do you have any thoughts here? I know you use the node library.

Hello @dennisedson

Yup I made it two calls for now, thank you.

Hi sir, can you show me how did you do it in two calls sir. Im struggling too :slightly_smiling_face:

I don’t know of a way to do it in one call. But after creating the deal, the second call is one line like:

await this._client.crm.contacts.associationsApi.create(contactId,'deal',dealId,'contact_to_deal')

Phil

Could you share the code you used to associate a contact wiht a deal? I’m struggling to understand what the API expects in the association type field. Thanks!

After creating a deal use this endpoint:

https://api.hubapi.com/crm/v3/objects/deals/{DEALID}/associations/Contact/{CONTACTID}/3?hapikey={APIKEY}