I have DealAssociations, CompanyAssociations and ContactAssociations. All of them have columns: Id, AssociationId, Type, TypeId, TypeName. Is there a way to extract all of the rows that I have but only columns Id and AssociationId? Currently I’m trying different endpoints and can’t get any results. I don’t want associations for specific Id, but want all the data.
Also, I don’t know which endpoint gets DealPipelines and DealPipelineStages.
Hi @APetak
To extract all the rows from Deal Associations, Company Associations, and Contact Associations in HubSpot while only retrieving the Id and AssociationId columns, you need to use the appropriate API endpoints for associations. Here’s how you can approach the problem:
1. Extracting all Association Data (Deal Associations, Company Associations, Contact Associations):
HubSpot offers different endpoints to manage associations between records like Deals, Contacts, and Companies. You want to extract associations, but only with specific columns (Id and Association Id). Here’s how to get all the association data:
A. Get All Associations for Deals:To get all associations for Deals, you would generally use the GET /crm/v3/objects/deals/{dealId}/associations/{toObjectType} endpoint. But since you want all associations (not specific ones), you might want to use the Search API for getting associations.
Example API to get Deal Associations:
GET /crm/v3/objects/deals/associations/contacts
This would return all contacts associated with the deals. You can also specify the type (e.g., contacts, companies) in the URL.
B. Get All Associations for Contacts:
Similarly, for Contact Associations, you would use:
GET /crm/v3/objects/contacts/associations/deals
C. Get All Associations for Companies:For Company Associations:
GET /crm/v3/objects/companies/associations/deals
2. Filter only the necessary fields (Id and Association Id):You will likely need to use pagination to handle large data sets if you have many associations. Since you only need the Id and AssociationId, you can either:
- Retrieve all the association data first and then process/filter it on your end.
- Use the
propertiesparameter in your request to specify the columns you want, though HubSpot’s API for associations might not let you directly limit only toIdandAssociationId.
The properties parameter typically allows you to specify which properties to return for each record, though for association data, you might get a more complex response, and then you’ll need to filter out the unwanted fields.
For example:
GET /crm/v3/objects/deals/associations/contacts?properties=id,associationId
If the API does not allow you to directly filter, retrieve all the data and then parse it to extract only the Id and AssociationId.
3. Deal Pipelines and Deal Pipeline Stages:To get the Deal Pipelines and Deal Pipeline Stages, HubSpot provides the following endpoints:
A. Get Deal Pipelines:
bash
GET /crm/v3/pipelines/deals
This will return all deal pipelines, including details such as the pipeline ID and its name.
B. Get Deal Stages for a Pipeline:
For each pipeline, you can get its stages:
GET /crm/v3/pipelines/deals/{pipelineId}/stages
This will provide you with the stages associated with a particular deal pipeline.
Summary of the API Endpoints You Need:
- Get all Deal Associations:
GET /crm/v3/objects/deals/associations/contactsGET /crm/v3/objects/deals/associations/companies
- Get all Contact Associations:
GET /crm/v3/objects/contacts/associations/dealsGET /crm/v3/objects/contacts/associations/companies
- Get all Company Associations:
GET /crm/v3/objects/companies/associations/dealsGET /crm/v3/objects/companies/associations/contacts
- Deal Pipelines:
GET /crm/v3/pipelines/deals
- Deal Pipeline Stages:
GET /crm/v3/pipelines/deals/{pipelineId}/stages
Let me now if you have any questions.
Hi, thanks for you reply, but those endpoints just show null for me.
I have tried using GET /crm/v3/objects/contacts?associations=companies,deals and I can get all contacts with its associations. But the problem is, that I want to get the contacts only created in past 7 days, for which i need to use POST /crm/v3/objects/contacts/search. This means that I can get only one of that, there is no way to use GET and filter or use POST and get associations. Any possible solutions for that?
Thank you for your reply! I understand the challenge you’re facing when trying to filter contacts created in the past 7 days and include their associations at the same time.
Unfortunately, as you’ve observed, the GET /crm/v3/objects/contacts endpoint with associations doesn’t support filtering by creation date directly. On the other hand, the POST /crm/v3/objects/contacts/search endpoint allows filtering but doesn’t return the associated records (like companies or deals).
Here are a few possible solutions for you:
1. Combine Two API Calls
- Step 1: Use POST /crm/v3/objects/contacts/search to filter contacts created in the last 7 days. This will give you the contact IDs.
- Step 2: Once you have the list of contact IDs, use GET /crm/v3/objects/contacts/{contactId}?associations=companies,deals to retrieve the associations for each contact. You’ll need to make individual calls for each contact.
While this requires multiple requests, it allows you to filter by creation date and still retrieve associations.
Hi @APetak
for any information about the API usage
I’d suggest you visit the devolpers page
where you’ll find the information.
Hope this helps
Hi, I’m aware of that page, but still couldn’t get it to work.