Skip to main content

I need to add over 200 users to my Klaviyo newsletter list using the API. While I know the manual process of uploading a CSV file, I want to automate this weekly task via the API. The endpoint I plan to use is:

https://a.klaviyo.com/api/lists/{List ID}/relationships/profiles/

However, it requires a user profile ID, which I don't have. I can retrieve the profile ID using the following endpoint:

https://a.klaviyo.com/api/profiles?filter=equals(email,"abc@gmail.com")

But, given the large number of users, I want to avoid making individual API calls for each email to fetch the profile ID.

MUST be checked against unsubscribe list in Klaviyo before added. When contacts are added to a list, they are subscribed even if they have previously unsubscribed. This is a critical step to comply with spam rules.

Hi ​@Arif Astori

  1. The API for adding users to list works for up to 1000 at a time. You are good to use that.
  2. Please use the get_profiles API in order to list profiles for up to 100 emails at a time. (GET https://a.klaviyo.com/api/profiles)
  3. In order to check whether those profiles are suppressed, you can use the same get_profiles API. However, you can also pass any filter and get all of the profiles for the candidate emails. The result of get_profiles should indicate for each profile whether it is suppressed. If it is, then you can exclude it.

    This is documentation on filtering in Klaviyo JSON:API. You don't need to filter on equals() many times if you have the list you can filter on any() any return all items matching the any filter instead of one item matching the equals filter
    https://developers.klaviyo.com/en/docs/filtering_

I hope this helps!
~Chloe


To automate this process efficiently, you can bulk check profiles against the unsubscribe list by using the List Unsubscribed Profiles API endpoint first, then proceed with adding the profiles only if they are not unsubscribed. To avoid fetching individual profile IDs for each email, consider using the Batch API to retrieve profile IDs for multiple users in one request.

Feel free to reach out if you need help with the code implementation or further automation!


Reply