HubSpot Ideas

vcheloudiakof

Get contact by email api/v3

I can get contact by email using API v1, but couldn't find any way to do so via v3.

Is there a solution ?

10 Replies
CSwart
Participant

I am having some trouble with this as well have you solved the issue?

vcheloudiakof
Participant

I did not find any solutions..

CBN
Top Contributor
digs
Member

I finally managed to get this to work.  If you look at their description under contacts: https://developers.hubspot.com/docs/api/crm/contacts it says the following:

"The idProperty query parameter doesn't appear on the Endpoints tab due to technical limitations, but it can be used for contacts exclusively with email. To use an email address as the unique identifier, set the idProperty as email and enter the email address in place of the contact ID. This should be set as a query parameter rather than added to the request body."

 

so the url request would be: 

https://api.hubapi.com/crm/v3/objects/contacts/ + email_address + ?idProperty=email
CBN
Top Contributor

Thanks @digs - I will try this later today as we do have customers with multiple emails and we want to find the correct contact no matter which email they use.

MBrien
Member

Also looking to solve this but with the ruby client https://github.com/HubSpot/hubspot-api-ruby - anyone else been able to use this for fetching a contact by email?

BThapa2
Member

@MBrien  this worked for me 

 client = Hubspot::Client.new
 client.get_by_id('test@email.com', {archived: false, id_property: 'email'})

 

PaulOomple
Member

Since they keep messing with their code, here's what I've found works with version 15.0.1 of the gem

# In initializer
$hubspot = Hubspot::Client.new(access_token: ENV['HUBSPOT_ACCESS_TOKEN'])

# Find contact by email. Normally from a model 
email = 'test@test.com' 
hs_contact = $hubspot.crm.contacts.basic_api.get_by_id(contact_id: email, id_property: 'email', archived: false) rescue nil

 

ASingla5
Member

To get more new clients 

ASingla5
Member

By preparing them to reach