Morning Team,
I hope you guys are doing well. I am working in a project where i need to fetch all contacts exists in contactlist using V3 endpoints. Could you please guide me in doing that? I dont find any straight endpoint to achieve the same.
I am using below endpoint
https://api.hubapi.com/crm/v3/objects/contacts
But it is giving all the contacts in the account. But i would like to get contacts only in specific contactlists.
Thanks
Hey @RKOSURI,
To fetch contacts from a specific contact list in HubSpot using the V3 API endpoints, you’ll need to follow a couple of steps, as there’s no direct V3 endpoint for fetching contacts in a specific contact list. Instead, you can use a combination of endpoints to achieve this.
- To retrieve a list by name, make a GET request to /crm/v3/lists/object-type-id/{objectTypeId}/name/{listName}. The objectTypeId is the ID that corresponds to the type of object stored by the list. See the full list of object type IDs.
- To retrieve an individual list by ILS list ID, make a GET request to /crm/v3/lists/{listId}. Learn more about finding the ILS list ID below.
- To retrieve multiple listsby ILS list ID, make a GET request to /crm/v3/lists and include a listIds query parameter for each list. For example: ?listIds=940&listIds=938.
@AddaxLab Thanks for your reply. I think we are pretty close to the solution. The endpoints you mentioned are related to the contactlists. I tried the above endpoints already and those are giving me the details of the contactlist but not the contacts inside these contactlist. I have already implemented an approach to fetch the contactlists using V3. I have contactlist Id and name handy. my application just need an endpoint which brings all contacts inside the specific contactlist.
Hey @RKOSURI,
Here is no one API endpoint to retrieve all contacts from contact list, but you can do it in 2 steps
- Retrieve all members from a list with a GET request to https://api.hubapi.com/crm/v3/lists/{listId}/memberships (replace {listId} with your actual id). Here, you retrieve a list of all member’s (contacts in our case) records ids. Like that:
{ “results”: [ { “recordId”: “19625561285”, “membershipTimestamp”: “2024-07-08T13:22:18.815Z” } ], “total”: 1 }
2. Get contact IDs from the response and map them to body payload for the next POST request to https://api.hubapi.com/crm/v3/objects/contacts/batch/read
const body = { propertiesWithHistory: [“string”], inputs: [ { “id”: “19625561285” }, // … ADD MORE IDS HERE FROM THE RESPONSE OF THE PREVIOUS REQUEST ], properties: [“firstName”, “email”, “lastName”] // ADD PROPERTIES HERE };
Hey @RKOSURI,
1. Here is no one API endpoint to retrieve all contacts from contact list, but you can do it in 2 steps
Retrieve all members from a list with a GET request to https://api.hubapi.com/crm/v3/lists/{listId}/memberships (replace {listId} with your actual id). Here, you retrieve a list of all member’s (contacts in our case) records ids. Like that:
2. Get contact IDs from the response and map them to body payload for the next POST request to https://api.hubapi.com/crm/v3/objects/contacts/batch/read