APIs & Integrations

YFeng
Participant

How to get newly created Contacts and their associated Deals

SOLVE

Hello experts,

 

My use case is to Get all contacts that were created every 5 mins and return the contacts and their associated Deals properties. I can get all Contact properties, but I wonder how to get all Deals properties that are associated with those newly created contacts. So is this correct? 1. Make an API call first to associate Contacts and Deals. 2. Make another call to get the newly created Contacts and their associate Deals. What is the second step request should look like? I used the Search Contact API but what should be the filers? 

 

YFeng_0-1621018559986.png

 

 

Thanks,

Yvonne 

 

0 Upvotes
1 Accepted solution
zaklein
Solution
Contributor | Platinum Partner
Contributor | Platinum Partner

How to get newly created Contacts and their associated Deals

SOLVE

Hi @YFeng 

Unfortunately, the Search CRM endpoint does not support the "associations" parameter in the query string (not all HubSpot API endpoints support the same query string parameters - you'll need to check each endpoint individually using HubSpot API docs). As such, you'll probably have to perform a couple more API calls than you were originally expecting. Based on how you've described your case, here's an option you may like to pursue (assuming the Contact records are already associated with the relevant Deal records):

  1. Perform a CRM Search to return recently created Contacts (as per the screenshot you've already shared)
  2. Use the returned Contact IDs from Step 1 to "read a batch of associations"
  3. Use the returned Deal IDs from Step 2 to "read a batch of deals by internal ID" (you'd specify your target Deal properties within the query string of this request)

I hope that's helpful. Let me know if you have any follow up questions.

All the best,

Zach

View solution in original post

zaklein
Solution
Contributor | Platinum Partner
Contributor | Platinum Partner

How to get newly created Contacts and their associated Deals

SOLVE

Hi @YFeng 

Unfortunately, the Search CRM endpoint does not support the "associations" parameter in the query string (not all HubSpot API endpoints support the same query string parameters - you'll need to check each endpoint individually using HubSpot API docs). As such, you'll probably have to perform a couple more API calls than you were originally expecting. Based on how you've described your case, here's an option you may like to pursue (assuming the Contact records are already associated with the relevant Deal records):

  1. Perform a CRM Search to return recently created Contacts (as per the screenshot you've already shared)
  2. Use the returned Contact IDs from Step 1 to "read a batch of associations"
  3. Use the returned Deal IDs from Step 2 to "read a batch of deals by internal ID" (you'd specify your target Deal properties within the query string of this request)

I hope that's helpful. Let me know if you have any follow up questions.

All the best,

Zach

dennisedson
Community Manager
Community Manager

How to get newly created Contacts and their associated Deals

SOLVE

@zaklein , any chance you could help out here?

Thanks,

Dennis




HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show
0 Upvotes