Skip to main content
Contributor I
April 17, 2024
Solved

Klaviyo API - Using Phone Number to Filter Out Profiles is Returning No Results

  • April 17, 2024
  • 4 replies
  • 197 views

Hello,

I am trying to use the Klaviyo API in order to access a customer profile by using this endpoint https://developers.klaviyo.com/en/reference/get_profiles

 

I want to filter out all the profiles by phone_number to get a specific profile.

Right now, when I filter out by the email, I can find the profile with the associated phone number. However, when I take that same phone number and filter with that number, no records are found. I have tried this with 2 different profiles.

This is the endpoint: https://a.klaviyo.com/api/profiles/?filter=equals(phone_number,"+19876543210")

I am using a mock phone number, but the real one is taken from the same profile I find when I call https://a.klaviyo.com/api/profiles/?filter=equals(email,"customer@email.com")

The customer has 'Accepts SMS': True

Please help?

This topic has been closed for replies.
Best answer by jason-myers

Hi Nicholas,

 

Try encoding the plus sign, which is a special character in urls.  So the phone number would look like: “%2B19876543210”

 

Thanks,

Jason

4 replies

Klaviyo Employee
April 18, 2024

Hi Nicholas,

 

Try encoding the plus sign, which is a special character in urls.  So the phone number would look like: “%2B19876543210”

 

Thanks,

Jason

Contributor I
April 18, 2024

This works. Thank you.

Contributor II
April 19, 2024

I have a similar question. Can someone please help, I am stuck. It may be something very basic as I am new.

So looking at this example:

?filter=and(equals(first_name,"Jane"),equals(email,"jane@klaviyo-demo.com"))

So instead of “Jane” and "jane@klaviyo-demo.com", I want to pass on a Variable, so how do I do that - syntax wise.

My goal is to get profile data based on an email (which is provided by the previous step and stored in two different variables)

Thanks,

Shaz

Contributor I
April 22, 2024

Hey Shaz, depends on what language you are coding. I’ll just paste what I have, it works for both email and phone number.

 

url = f"https://a.klaviyo.com/api/profiles/?filter=equals({find_by},\"{encoded_value}\")"

In your case, “find_by” is email. I think what you might have been missing is the escape characters to include the quotation marks.