Skip to main content

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

Hi @veroca!

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

 

Best,

Brian


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!


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.


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


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

Entering: 

/api/profiles/?filter=equals(email,"'.$email.'")&fieldsdprofile]=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,y"' . $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($responser'data'])) {    return false;}

Reply