Skip to main content
Contributor I
September 28, 2021
Solved

Identify Profile API (check if profile exists with email)

  • September 28, 2021
  • 3 replies
  • 1526 views

Hi all,

I need to check if a profile exists on my custom form submission. I already have the custom form submitting to Klaviyo through an API call. What I’d like to do is add another call before this, and check if the email exists already.

 

I’m attempting to use the example shown here: https://apidocs.klaviyo.com/reference/track-identify#identify-get

 

When I run this code, it returns a 1 every time, whether the email / profile exists or not.

Is there a way to check if the profile exists through this endpoint?

 

const options = {
method: 'POST',
headers: {Accept: 'text/html', 'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
data: '{"token": "PUBLIC_KEY","properties": {"$email":"ben.franklin@klaviyo.com"}}'
})
};

fetch('https://a.klaviyo.com/api/identify', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

 

Many thanks for any advice.

    This topic has been closed for replies.
    Best answer by Dov

    Hi @bethanyfish,

    Thanks for sharing this question with the Klaviyo community.

    The only other way is to use the Lists API endpoint to look for the Profile IDs of multiple profiles in a list/segment: https://www.klaviyo.com/docs/api/v2/lists#get-members-all

    You can create a segment of everyone in your account with the following segment logic: Properties about someone > email contains > @. 

    3 replies

    Contributor I
    September 28, 2021

    I should mention I’m also open to other means of doing this. I’m just hoping to avoid having to create a solution with a private API key.

    Here’s the code I’m using to add the user to our list:
     

    const settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://manage.kmail-lists.com/ajax/subscriptions/subscribe",
    "method": "POST",
    "headers": {
    "content-type": "application/x-www-form-urlencoded",
    "cache-control": "no-cache"
    },
    "data": {
    "g": listID, // list ID is variable
    "email": emailInput // email from input
    }
    }

    $.ajax(settings).done(function (response) {
    // form success stuff
    });

     

    This works without problem. 

    GOAL: Add an additional check before running this to see if email already exists.

    Contributor I
    September 28, 2021

    As a final follow up… if you read this & think this isn’t possible with a public API key, please let me know. I can dig into doing this with GraphQL, but hoping for a quicker solve.

    Dov
    DovAnswer
    Klaviyo Alum
    September 30, 2021

    Hi @bethanyfish,

    Thanks for sharing this question with the Klaviyo community.

    The only other way is to use the Lists API endpoint to look for the Profile IDs of multiple profiles in a list/segment: https://www.klaviyo.com/docs/api/v2/lists#get-members-all

    You can create a segment of everyone in your account with the following segment logic: Properties about someone > email contains > @. 

    DD