Solved

Is there a way to search for a profile by their email using the API ?

  • 1 October 2021
  • 14 replies
  • 3201 views

Badge +2

Hi,

 

I’m using the API to search for profiles using their email but it appears to be not available.

Why is that ? It doesn’t make sense that we don’t have CRUD operations on profiles….
 

 

icon

Best answer by shtlrs 4 October 2021, 17:31

View original

14 replies

Userlevel 7
Badge +60

Hello @shtlrs,

Thanks for sharing your question with the Klaviyo Community!

To search for a profile via a user’s email address through API, you’ll first need to make a GET request for the List and Segment Members endpoint. This in turn will return a list of profile objects such as the profile’s ID, email address, phone number, etc. From here you would then be able to loop through the data in search of the profile that matches the email address you are searching for. 

@jallain has a great explanation and write up of this in a similar Community post which i’ve included below. I’ve also included some other Community post which touch upon this subject that may be helpful for you to review.

I hope this helps!

David

Badge +2

Hi @david.to , 

Thanks for the answer. But the problem is that I don’t want to search for a profile in a list. Because If I have 400 lists and I’m looking for 1 profile, it wouldn’t make sense to loop in all 400 to just look for one profile, that’s very resource intensive and unfortunate.

I just found out that we could use this endpoint

"https://a.klaviyo.com/api/v2/people/search?api_key={key}&email={email}"

But this isn’t documented, and I think it should.

Cheers,
Amrou.

Userlevel 7
Badge +60

Hello @shtlrs,

Thanks for surfacing that endpoint! I’ll share this detail with our Product Team to provide better documentation on this and to incorporate it into our API Documentation.

As always, thanks for providing your feedback and for being a part of the Klaviyo Community!

David

Badge +1

Hi David,

Any update to this endpoint being added the to API documentation?  I have created a support request in reference to this endpoint in hopes of batching email addresses for the search.  Best case the response would return email/id combos. 

Is that something that will be possible?

Thanks in advance,
Paul

 

Userlevel 7
Badge +60

Hello @paulfl,

Thanks for sharing your feedback! I have not received any updates regarding this endpoint being added to the API Documentation yet. However, I am aware that our engineering and product team has received the request!

I’ll further tack on your suggestion surrounding returning email/id combos to the endpoint as well as at present, this is not yet feasible.

Thanks for your patience and for being a part of the Klaviyo Community!

David

Badge +2

Hi,

are there news about this endpoint? Is it safe to use it or still under testing as it has no documentation yet and may change?

We need to manage profiles and subscription/unsubscription via API and this call would match our needs: we would create a new profile to be assigned to a list if 404 is returned or manage its consent with unsubscribe/re-subscribe from/to list if 200 is returned.

 

Thank yuo

fabrizio

Userlevel 7
Badge +60

Hey @efferre68,

As our Klaviyo API usage grows, our documentation team is working hard towards collating any less frequently used endpoint to be included in our guides. Although this specific endpoint is not documented within our API Documentation, it is absolutely safe to use!

David

Badge +2

Thank you for reply David!

Our concern is that it might be changed for some reason as it is not documented yet, but if safe to use then more than fine.

I had already tested it and via Postman it was 100% matching our needs, just once implemented on our platform we got an error message, but think it might be due to a wrong call structure we’ve set, perhaps it has to be specified some other way.

fabrizio

Badge

Hey, this endpoint doesn’t seem to work for me.
I’ve tried the following with a valid email address that’s in my profiles:
https://a.klaviyo.com/api/v2/people/search?api_key={api_key}&email={email}

However, I get the following response: There is no profile matching the given parameters.
 

Any idea?

Userlevel 7
Badge +60

Hey @ReeceC,

I would first suggest double checking and making sure the API Key you’re using is one generated from the respective account you are testing in. I’ve seen a number of instances where users who have access to multiple accounts inadvertently use the incorrect key associated within a different account. 

Additionally, I would also ensure that the email address/profile you’re searching for is in fact a profile within your respective Klaviyo account. The simplest way to confirm this would be entering the email address into the search bar at the top of the Klaviyo interface and seeing the results that are returned. Using the in-app search tool would function similarly to the endpoint where if there is no contact/profile within your Klaviyo account which has this email address, you’ll receive a “We couldn't find anyone matching your search” notice.

David

 

Badge +3

Hey, this endpoint doesn’t seem to work for me.
I’ve tried the following with a valid email address that’s in my profiles:
https://a.klaviyo.com/api/v2/people/search?api_key={api_key}&email={email}

However, I get the following response: There is no profile matching the given parameters.
 

Any idea?

Remember that you have to URL encodethe email if it contains odd characters.


I’d just like to point out one mighty sketchy thing with this endpoint.
If there are multiple profiles with the same email this endpoint will still only return one id.
And I have absolutely no idea if there is any rhyme or reason behind which user ID gets returned.

Userlevel 7
Badge +60

Hey @Henrik Sommerland,

Are you by chance identifying your profiles/contacts with a custom identification method such as an external id ($id) property?

Normally, there wouldn’t be multiple profiles with the same associated email address. Since the default identification method uses an email address (using the $email key), profiles would be de-duplicated. Natively, this de-duplicative process spans the whole of Klaviyo and stands even if contacts/profiles are added to your Klaviyo account from a variety of sources. This is, with the exception of using an alternate custom identification method using an $id key. 

As called out in our Getting Started with Track and Identify APIs Developer Documents:

If you choose to use a unique identifier via the $id key, you will be responsible for identity management within your Klaviyo account. You must ensure every call you make maps the correct $id to the associated $email. Calls sent with only an $id value will cause Klaviyo to create profiles without an associated $email. If a call then comes in for the same person, but only identifies them via their $email, a permanent duplicate profile will be created for the same person.

The $id key should never be used to track profiles anonymously, as this has a high potential of creating multiple profiles for individuals in your account if not set up thoughtfully. Only use $id if a given person has a known $email and their associated ID will never change (eg. an account ID in your own system).

 

This means that often times, one returning profile ID would be all you need as each email address would have a unique profile in Klaviyo. 

David

 

Badge +3

@David To 

Thank you!!!!
We have been scratching our heads about why we were having duplicate accounts in some cases :)
Now we know what to look for!

Badge

Since this post is still relevant for Google, I just want to mention, that you can simply use the new /api/profiles endpoint together with a filter parameter for the email address “?filter=equals(email,"jane@doe.com")”.

See:
https://developers.klaviyo.com/en/reference/get_profiles
https://developers.klaviyo.com/en/docs/filtering_

Kind regards

Reply