APIs & Integrations

ilron
Member

How to fetch contact's all emails with API v3?

SOLVE

Hello! I am using CRM API (v3) https://developers.hubspot.com/docs/api/crm/contacts to fetch contacts from HubSpot. Everything is good, however if the contact has several emails, I still receive onle primary one. After googling I found this: https://developers.hubspot.com/docs/methods/contacts/get-secondary-email-addresses-by-vid

 

Yes, it works and I am able to receive secondary emails. But why do I need to use one more API request and use API v1? If there any way to receive ALL user's emails via single request?

I am using 

 client.crm.contacts.basicApi.getPage

 How to get secondary emails there? Thanks.

1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

How to fetch contact's all emails with API v3?

SOLVE

Hey @ilron,

 

Currently, the way to get secondary emails will have to be done through the Get the secondary email addresses for a contact endpoint.

 

I believe this is because secondaryEmail address is not set as a contact property but rather a separate entity. 

 

That said, if you haven't already, I'd recommend jumping over to the HubSpot Ideas Forum and posting this idea there so that it's visible to the HubSpot product team and other HubSpot customers and developers. Hopefully this will gather more interest.

View solution in original post

13 Replies 13
CBN
Top Contributor

How to fetch contact's all emails with API v3?

SOLVE

This is the "accepted" solution, which is just an UGLY hack:

 

https://community.hubspot.com/t5/APIs-Integrations/Search-Contacts-for-Secondary-Mail/m-p/358756

CBN
Top Contributor

How to fetch contact's all emails with API v3?

SOLVE

Waste of time, resources and completely obscure - no transparency for the user (me). The idea in software development is that you hide the implementation and expose your interface as simple, nice and user friendly as possible.

 

This 101 concept again seems to be lost with the HubSpot API.

 

CBN
Top Contributor

How to fetch contact's all emails with API v3?

SOLVE

I agree @ilron THIS IS CRAZY!

0 Upvotes
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

How to fetch contact's all emails with API v3?

SOLVE

Hey @ilron,

 

Currently, the way to get secondary emails will have to be done through the Get the secondary email addresses for a contact endpoint.

 

I believe this is because secondaryEmail address is not set as a contact property but rather a separate entity. 

 

That said, if you haven't already, I'd recommend jumping over to the HubSpot Ideas Forum and posting this idea there so that it's visible to the HubSpot product team and other HubSpot customers and developers. Hopefully this will gather more interest.

chrisny454
Member

How to fetch contact's all emails with API v3?

SOLVE

Wendy, I know this is an old thread, but your recommended way to get the secondary email is using a version 1 API endpoint for Hubspot which is being sunset in November 2022. Is there a way to get the secondary email for a contact using the V3 API?

0 Upvotes
Aileron
Participant

How to fetch contact's all emails with API v3?

SOLVE

Update: 

I stumbled across this page - and I tried using hs_additional_emails as a property field when retrieving contacts from the API, like &properties=hs_additional_emails - and it will be returned as a contact property. It is not really well documented as this field does not show up in the HS GUI as a contact property.

öä
Participant

How to fetch contact's all emails with API v3?

SOLVE

Agreed, this is the solution.

0 Upvotes
Aileron
Participant

How to fetch contact's all emails with API v3?

SOLVE

Don't be fooled - even though the field is named "hs_additional_emails", it seems to return only one additional email address. If a contact has more than two email adresses (which I now know it can have), you might not get all adresses of a contact. So, to get all adresses, you'll have to call a separate endpoint. I hate to say it, but this is very poor API design, unfortunately.

iAbbasAhmad
Participant

How to fetch contact's all emails with API v3?

SOLVE

I don't think that's true. I am able to get all the emails for a contact inside the hs_additional_emails field. The additional emails are sent as a string separated using a semi-colon ; and using Array methods like hs_additional_emails.split(";")for JavaScript for example, one can get an array of additional email addresses.

öä
Participant

How to fetch contact's all emails with API v3?

SOLVE

I agree with you on the API design. I tested contacts with multiple email addresses and the "hs_additional_emails" field return them separated by ";". So the data in the field looked like "name1@example.com;name2@example.com".

Aileron
Participant

How to fetch contact's all emails with API v3?

SOLVE

It's a while that I tested that, I don't think it worked like that when I tested - need to try that out again, thx a lot! Maybe I was confused by this being a string field when expecting an array. Thx a lot!

0 Upvotes
CBN
Top Contributor

How to fetch contact's all emails with API v3?

SOLVE

There is an UGLY workaround described there. How about just making it work so I can get all emails for one contact or search for a contact based on ANY email?

0 Upvotes
ilron
Member

How to fetch contact's all emails with API v3?

SOLVE

This is crazy that I am forced to do an extra API call and can't just get ALL data via 1 API call. Very weird software design...