APIs & Integrations

devphoenix
Member

GET companies and deals more details in the API

Hi team,

Could you please help here.

{{baseUrl}}/crm/v3/objects/contacts?associations=companies,deals

in the response of this API, we are getting this...
{
"id": "101",
"properties": {
"createdate": "2023-07-24T08:53:58.795Z",
"email": "gourav.gupta+hs@brevo.com",
"firstname": "Contact",
"hs_object_id": "101",
"lastmodifieddate": "2024-05-22T10:39:17.610Z",
"lastname": "B"
},
"createdAt": "2023-07-24T08:53:58.795Z",
"updatedAt": "2024-05-22T10:39:17.610Z",
"archived": false,
"associations": {
"companies": {
"results": [
{
"id": "20861273154",
"type": "contact_to_company"
},
{
"id": "16682150751",
"type": "contact_to_company_unlabeled"
},
{
"id": "20861273154",
"type": "contact_to_company_unlabeled"
}
]
},
"deals": {
"results": [
{
"id": "19489433890",
"type": "contact_to_deal"
}
]
}
}
}

 

 

 

 

 

Is it possible to include more details, such as the names of companies and deals, in the response?

Example response:

json
Copy code
{ "id": "20861273154", "type": "contact_to_company", "name": "Company A" }

If this feature is not currently available, could you please add it to the to-do list? This enhancement would greatly improve our ability to use your APIs more effectively.

12 Replies 12
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

GET companies and deals more details in the API

Hi @devphoenix ,

 

Using the regular REST API endpoints that HubSpot offers, you will need a second batch API request to retrieve the details of the associated objects. Retrieving associated records through a GET request currently only returns the ID and association label.

However, if you construct a GraphQL query, you should be able to retrieve the properties you are looking for in a single API call. 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
devphoenix
Member

GET companies and deals more details in the API

HI @Teun @Humashankar @Jaycee_Lewis 

Thanks for your response, it is possible to have the assoicated object information in these API's,

{{baseUrl}}/crm/v3/objects/companies/16682150751?associations=contacts,deals
like in the response I will get 

devphoenix_0-1718014187429.png

 

or 

use {{baseUrl}}/crm/v3/objects/companies/search

"associations": ["deals", "contacts"] will extent with deal name and contact email information

 

devphoenix_1-1718014219509.png

 

Could you guys please help here.
Thanks

0 Upvotes
Humashankar
Top Contributor

GET companies and deals more details in the API

Hi @devphoenix 

Both methods you mentioned can achieve the goal of retrieving associated object information.

Hope this helps - Happy to help further!!

Regards

Humashankar VJ
HubSpot Community Champion and enthusiast | Engineering Manager
0 Upvotes
devphoenix
Member

GET companies and deals more details in the API

@Humashankar, I've been trying hard for the past few days but haven't received the response I mentioned. Could you please share the complete method or CURL? Your help would be greatly appreciated. Thanks in advance!

0 Upvotes
Humashankar
Top Contributor

GET companies and deals more details in the API

Hi @devphoenix 

Retrieve company data with nested includes,

GET {{baseUrl}}/crm/v3/objects/companies/16682150751?associations=contacts(id,email),deals(id,dealname)

This API request fetches information about the company with ID 16682150751, including:

  • Contacts - ID and email address
  • Deals - ID and deal name

Believing the "email" and "dealname" properties exist.

Can you try and get us with the outcome - will see how we can fix this.

Regards

Humashankar VJ
HubSpot Community Champion and enthusiast | Engineering Manager
0 Upvotes
devphoenix
Member

GET companies and deals more details in the API

Thanks @Humashankar for being so helpful.

But it didn't worked out.

devphoenix_0-1718038252842.png

Could you please help more here !!

and with {{baseUrl}}/crm/v3/objects/companies/search

"associations": ["deals""contacts"] how to pass these in the body of the CURL?

Thanks

0 Upvotes
Humashankar
Top Contributor

GET companies and deals more details in the API

Hi @devphoenix 

 

The "associations": ["deals", "contacts"] section should be included within the JSON request body, not as a separate parameter in the URL
Can you try the below one and give a try-

 

curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"filterGroups": [
{ "filters": [ { "propertyName": "name", "operator": "EQ", "value": "Company Name" } ] } ### Replace "Company Name" with your search criteria
],
"associations": ["deals", "contacts"]
}' \
"{{baseUrl}}/crm/v3/objects/companies/search"

 

Regards

Humashankar VJ
HubSpot Community Champion and enthusiast | Engineering Manager
0 Upvotes
devphoenix
Member

GET companies and deals more details in the API

devphoenix_0-1718040966888.png

@Humashankar Don't worked out this one too.

search API curl

--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{key}}' \
--data '{
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_lastmodifieddate",
"operator": "GT",
"value": "1980-06-10T00:00:00.000Z"
}
]
}
],
"associations": [
"deals",
"contacts"
]
}'

Companies API

curl --location 'https://api.hubapi.com/crm/v3/objects/companies/16682150262?properties=name%2Cindustry%2Cnumberofemp...)' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{key}}'

"It would be very helpful if these APIs work as expected, allowing me to retrieve the necessary details, including the associated contact ID and email, as well as the associated deal ID and deal name."
0 Upvotes
devphoenix
Member

GET companies and deals more details in the API

Thank you for the answer! 😊

Could you please share the steps and APIs to achieve this? It will be more effective for me.

0 Upvotes
Humashankar
Top Contributor

GET companies and deals more details in the API

Hi @devphoenix 

HubSpot's Batch Read API enables efficient retrieval of detailed information for multiple objects (companies and deals) by leveraging their IDs. The below steps helps better.

 

  1. Obtain Association IDs by Extract the association IDs from the initial response, found in the "results" array for companies and deals (e.g., "id": "20861273154").
  2. Construct Batch Read Request by making use of the retrieved association IDs to build a new API call to the Batch Read endpoint (/crm/v3/objects/batch-read). Include the IDs in the request body to fetch comprehensive information for the specified objects in a single, efficient API call, utilizing the full potential of the Batch Read API

 

If you'd like to see a more streamlined experience, you can also submit a feature request to HubSpot by navigating to Ideas from the dropdown.

 

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

Humashankar VJ
HubSpot Community Champion and enthusiast | Engineering Manager
0 Upvotes
devphoenix
Member

GET companies and deals more details in the API

Thank you for the response, but I am not able to get the information I need. Could you please share the APIs with some examples? This would be very beneficial, and I would appreciate it.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

GET companies and deals more details in the API

Hey, @devphoenix 👋 This ended up getting flagged by the spam filter. I moved it out, so our community members can take a look. 

 

Talk soon! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot