Skip to main content
Solved

Using PHP SDK (API Revision: 2023-08-15) Can I get profile by email?

  • September 11, 2023
  • 5 replies
  • 305 views

Forum|alt.badge.img+3
  • Contributor III
  • 6 replies

Hi!

I’m transitioning from the old version to the new Klaviyo API. I’m using the php SDK  but I found an issue when createProfile() and now I think there is more than one issue.

So I’m thinking to use the raw PHP using this Klaviyo API Documentation

I found that we MUST HAVE the Unique ID (Klaviyo) of the user in order to getProfile, I dont have that ID saved on the database, we used to query by email.
I can save the Unique ID on the database from now on, but I would like to know if there is a way to getProfile by email instead of Unique ID or what could be the option here for the users that are already saved on Klaviyo and I dont have the Unique ID ?

Thank you

Best answer by Brian Turcotte

Hi @veroca!

My apologies for the delay here! To accomplish this, you could use the Get Profiles endpoint, but add a filter for email equals xyz

 

The PHP SDK supports this endpoint, and this method would avoid the issue you’re encountering.

 

Best,

Brian

View original

5 replies

Brian Turcotte
Forum|alt.badge.img+37

Hi @veroca!

I’m going to check on this with Engineering and I’ll update the thread ASAP!

 

Best,

Brian


Forum|alt.badge.img+3
  • Author
  • Contributor III
  • 6 replies
  • September 12, 2023

Thank you so much @Brian Turcotte, I just found out that we actually saved it in a different db. but I’m curious about what the engineering team will reply to you!! Thank you again for your response!


Forum|alt.badge.img+3
  • Author
  • Contributor III
  • 6 replies
  • September 20, 2023

Hi @Brian Turcotte Did you get any response about this?
Now this became a real problem to my company.
When we create a klaviyo profile $response = $this->klaviyoClient->Profiles->createProfile($body); we are waiting for the response in order to save the KlaviyoId in our database, but because, i guess, a timeout or limit rate happened, the profile was created on Klaviyo but we never got the response, so now we have a lot of users with a profile created on Klaviyo but is not a way for us to get those id, please I really appreciate your help with this issue.


Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • October 2, 2023

Hi @veroca!

My apologies for the delay here! To accomplish this, you could use the Get Profiles endpoint, but add a filter for email equals xyz

 

The PHP SDK supports this endpoint, and this method would avoid the issue you’re encountering.

 

Best,

Brian


Forum|alt.badge.img
  • Contributor I
  • 1 reply
  • December 6, 2023

I get a status code 200 no matter if it exists or not. 

Entering: 

/api/profiles/?filter=equals(email,"'.$email.'")&fields[profile]=email', [… 

 

Update: My bad. Had to return the response into array and then the data  

Works: 

$response = $this->client->request('GET', $this->api_url.'/profiles/?filter=any(email,["' . $email . '"])', [    'headers' => [        'Authorization' => 'Klaviyo-API-Key ' . $this->api_key,        'accept' => 'application/json',        'revision' => date('Y-m-d'),    ],]);$response = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);if (empty($response['data'])) {    return false;}