Skip to main content

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 ​@kenw222 

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 ​@kenw222! 

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