Hello,
I’m working on interation with Hubspot’s API in order to extract our deals using the
“https://api.hubapi.com/crm/v3/objects/deals ” endpoint.
At the beginnig, I tried the “V1” endpoint - https://api.hubapi.com/deals/v1/deal/paged
but the properties field didn’t work for me - it didn’t return the required fields
https://api.hubapi.com/deals/v1/deal/paged?hapikey=my_api_key&properties=dealname,dealstage,brand_id .
Therefore, I moved to the “https://api.hubapi.com/crm/v3/objects/deals ” endpoint.
It worked fine except to the fact that at this endpoint, it doesn’t return association.
I tried to add “includeAssociations=true” or “associations=” with Associtation ID or Associations’ name
Example:
https://api.hubapi.com/crm/v3/objects/deals?hapikey=my_API_key&properties=hs_object_id,hs_lastmodifieddate,budget_start_date,closedate,createdate&limit=100&associations=1,2,3
or
https://api.hubapi.com/crm/v3/objects/deals?hapikey=my_api_key&properties=hs_object_id,hs_lastmodifieddate,budget_start_date,closedate,createdate&limit=100&associations= associatedDealIds,associatedTicketIds
(associations - Array of stringsQuery param.A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.)
Neither of them worked.
My question is how can I use the “api.hubapi.com/crm/v3/objects/deals ” endpoint to include also associations? Or should I use the “https://api.hubapi.com/deals/v1/deal/paged ” and find a way to pass the parameters correctly?
I used this documentaion Accounts Dashboard | HubSpot
Thank you,
Anton.
Willson
February 11, 2020, 9:43am
2
Hi @antonr12
Taking a look through your question, I cannot see specifically the required query parameters needed to return associations for deals (feel free to correct me if I am mistaken).
As per the documenatation found here , you can find associations for deals using the associations.{objectType} pseudo-property.
For Deals, these are the supported association filters:
Object type Filter propertyName
deals associations.company,associations.contact,associations.ticket
As an example, your request URL would be the following:
POST https://api.hubapi.com/crm/v3/objects/Deals/search?hapikey={{hapikey}}
You’ll then include the sample request body as your filters:
{
"propertyName": "associations.contact",
"operator": "EQ",
"value": "ASSOCIATED_CONTACT_ID"
}
You’ll then get a response along the lines of:
"total": 21,
"results": [
{
"id": "id",
"properties": {
"amount": "17700",
"closedate": "2019-06-30T07:43:15.076Z",
"dealname": "Test",
"dealstage": "c51cd404-82cc-4c1c-9d95-a8a89f125251",
"pipeline": "default"
},
"createdAt": "2019-06-21T07:43:15.077Z",
"updatedAt": "2019-06-21T07:43:39.521Z",
"archived": false
},
// SNIPPET CUT //
I hope this helps!
Thank you for your response.
It helps but my intentions are to find out how to get the associations using the deals API
https://api.hubapi.com/crm/v3/objects/deals?hapikey=my_api_key&properties=hs_object_id,hs_lastmodifieddate,budget_start_date,closedate,createdate&limit=100&associations=? ??
The options to specify the association exists as a query field, I would like to find out in which format I should enter the parms there.
Thanks again,
Anton.
I added as part of the Query String;
https://api.hubapi.com/crm/v3/objects/deals?hapikey= KEY &associations=companies
And I get this returned from the beta endpoints:
"associations": {
"companies": {
"results": [
{
"id": "123456789"
}
]
}
},
You can then add more e.g.;
&associations=companies,contacts
And get more responses of associations;
"associations": {"companies": {
"results": [
{
"id": "123456789"
}
]
},
"contacts": {
"results": [
{
"id": "1234345678"
}
]
}
},
I added as part of the Query String;
https://api.hubapi.com/crm/v3/objects/deals?hapikey= KEY &associations=companies
And I get this returned from the beta endpoints:
"associations": {
"companies": {
"results": [
{
"id": "123456789"
}
]
}
},
You can then add more e.g.;
&associations=companies,contacts
And get more responses of associations;
"associations": {"companies": {
"results": [
{
"id": "123456789"
}
]
},
"contacts": {
"results": [
{
"id": "1234345678"
}
]
}
},
Great response!
Is there a way to get the name of the company besides de id?
Willson
February 13, 2020, 1:18pm
8
Hi @antonr12
The solution there from @MCullenSSG is correct with how the query parameters should be passed.
Simply appending the parameter to the Request URL with the form &associations=OBJECT should suffice to then return the ID of the associatied object.
I hope this helps!
It’s been over a year since this was solved, I’ve tried the &associations=companies approach, and I’m not getting ‘associations’ in they returned payload. I tried adding it in the post payload similar to ‘properties’ as an array, but that did not work either.
Is this still supposed to be working?
Update: this does work when using crm/v3/objects/deals/ but not crm/v3/objects/deals/search