Hello community,
I’m trying to get the contacts by DealId and I can’t with associations.
I’m doing something like:
$response = $this->hubspot->crm()->deals()->basicApi()->getById($dealId);
With this, I get the properties of a Deal but I can’t get the associated contacts. I tried some ways that I found to get the associations but I could’nt.
Any example about how to get the list of contacts for a Deal ID?
Thank you very much,
Best regards,
Hey, @JPadula
Did you get this worked out? If not, you might need to try a different approach.
You can make a request to the Associations API to return associated contacts to a deal by ID, for example.
GET /crm/v4/objects/{objectType}/{objectId}/associations/{toObjectType}
$dealId = 'your-deal-id';
$contactAssociations = $this->hubspot->crm()->associations()->getAll($dealId, 'contact');
// The documentation structures it like this
$client->crm()->associations()->v4()->basicApi()->getPage('deal', 1, 'contact', 500);
(1 = deal ID and 500 = limit in this example)
Then you can loop through the contact IDs to fetch each contact’s details using the getById method for contacts, either individually or in batches — [Contacts API endpoints](http://To retrieve a batch of specific contacts by record ID)
Have fun building! — Jaycee