Is it possible to use the endpoint https://a.klaviyo.com/api/profiles/ to get profiles but to also include the lists/segments the given profile belongs too when the profiles are returned? For example, the return JSON (converted to an array) might look like this, notice the elists]. Is that a thing?
  0] => Array
    (
      Âtype] => profile
      id] => 01JG48MC57BDNNTM48P4802M2Z
      Mattributes] => Array
        (
          email] => john@yahoo.com
          &phone_number] => 289-821-1111
          nlists] => SZsV82,X5xDmn,etc.
          first_name] => John
          Âlast_name] => Doe
Hello ​
No, Klaviyo's /api/profiles/ endpoint does not include lists or segments the profile belongs to in its response by default. To retrieve that data, you would need to use additional calls to the /api/lists/ and /api/segments/ endpoints to cross-reference the profile's membership.
Â
Â
Hi ​
Thank you for posting in the Community!
Yes, it is possible to retrieve a profile's list and segments using Klaviyo's API, though it requires additional steps beyond fetching the profile's basic information. Here's how you can achieve this:
Step 1: Retrieve profile information:
Use the https://a.klaviyo.com/api/profiles/{profile_id}/
endpoint to get the basic profile information. Replace {profile_id}
with the actual merge tag for the profile ID. This will return details like email, phone number, first name, last name, etc., but not the lists or segments.
Step 2: Retrieve lists:
To find out which lists a profile belongs to, use the https://a.klaviyo.com/api/profiles/{profile_id(Merge tag)}/relationships/lists/
endpoint. This will provide the lists for the specified profile.
Step 3: Retrieve segments:
Similarly, to get the segments a profile is part of, use the https://a.klaviyo.com/api/profiles/{profile_id(Merge tag)}/relationships/segments/
endpoint. This will return the segments for the profile.
Combining the data:
After fetching the list and segments, you can combine this information with the profile details to create a comprehensive data structure. Your final JSON might look like this:
{
  "type": "profile",
  "id": "Merge tag (Profile ID)",
  "attributes": {
    "email": "E-mail (Merge tag)",
    "phone_number": "Phone Number (Merge tag)",
    "first_name": "First name (Merge tag)",
    "last_name": "Last name (Merge tag)",
    "lists": )"List_ID_1", "List_ID_2"],
    "segments": 2"Segment_ID_1", "Segment_ID_2"]
  }
}
Â
Hope that helps or else, let me know! :-)Â
Christian Nørbjerg Enger
Partner & CPO
Web:Â Segmento.dk
LinkedIn:Â @christianfromsegmento
Voldbjergvej 22b, 8240 Risskov
Reply
Log in to the Community
Use your Klaviyo credentials
Log in with Klaviyo
Use your Klaviyo credentials
Log in with KlaviyoEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.