Closed ejfrancis closed 3 years ago
Hi @ejfrancis
Klaviyo does have an endpoint, currently undocumented, that allows you to look up a profile using their email address. The endpoint is api/v2/people/search
. We can add this endpoint to the SDK in the future. In the meantime, here's the request structure:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://a.klaviyo.com/api/v2/people/search',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_POSTFIELDS =>'{
"email":"email@example.com"
}',
CURLOPT_HTTPHEADER => array(
'api-key: PRIVATE_API_KEY',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Example response for a successful request:
{"id":"SOMEID"}
When creating a new profile it doesn't seem like it's possible to get the Profile ID (or any of the response object for that matter), so I can't make subsequent calls using the newly created Profile. There's also no API to retrieve profile via email, so I can't see how I can ever know the correct Profile ID associated w/an email.
Example:
$res
is just the number1
every time it's called