Klaviyo helps businesses collect massive amounts of data on their customers from the communications they interact with to metadata from their Active on Site sessions. Developers play a key role in unlocking the value in this data.
We will start by building a baseline understanding of concepts related to Klaviyo's APIs and build toward a step-by-step walkthrough of a complex use case centered around first-time, Black Friday customers.
This guide primarily makes requests on Klaviyo's newest generation of APIs using our Python SDK. However, direct HTTP requests are covered as well. Regardless of how you plan on interacting with Klaviyo's APIs, this guide should teach you something about how customer data in Klaviyo can be a driver for growth. Let's dive in!
The steps listed above are needed if you want to execute the code snippets shown in this guide. Those who are mainly interested to learn how Klaviyo's APIs work should be able to get the information without needing to run the notebook.
It is not strictly necessary to have a sandbox account with fake customer data in order to run this notebook. However, developers who are testing new functionalities should strongly consider it. Especially for use cases where you upload or change customer data, you want to make sure that you are not negatively impacting the data you have on your customers.
If you haven't worked with SDKs before (Software Development Kits), think of an SDK like a small library specific to a set of API endpoints.
Klaviyo's SDKs make working with our APIs easier by providing one-line methods for common tasks (e.g. how to update a customer's profile, change subscription status, etc.).
This walkthrough will make use of the Python language and Klaviyo's Python SDK. Klaviyo has released SDKs in Node
, PHP
, Python
, and Ruby
. Developers can find more information about Klaviyo's SDKs here.
If you are using one of those languages, Klaviyo highly recommends that you use our SDK to make API requests. The SDK performs a lot of best practices automatically under the hood (e.g. retry logic).
If you want to fully customize every part of your usage of our APIs, you are always free to make the calls directly (i.e. through HTTP requests).
This guide covers both direct API requests and requests sent through Klaviyo's SDK.
This tutorial assumes that Klaviyo's SDK is already set up locally. To check out how this is done, select the SDK version and language you want and follow the instructions given on the SDK github. For reference, you can download the SDK with a pip install
call like the one commented out below.
Setting up the SDK locally in your codebase is most important for frequent API users and/or developers setting up a production job. Developers who are just testing Klaviyo's API capabilities can start with direct HTTP requests on Klaviyo's endpoints.
For the best user experience reading this guide, please view it on NBViewer rather than natively in Github. Interacting with the guide on NBviewer cuts down on 404 errors when clicking internal links and better formats long code printouts.
You can find Klaviyo's API guides on NBViewer here.
# you may need to pip install the SDK for Klaviyo's current generation of APIs
# pip install klaviyo-api
### Libraries needed to run requests through pure python (using requests library)
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from datetime import datetime, timedelta
import random
import string
import json
### Library needed to run request through Klaviyo's python SDK
from klaviyo_api import KlaviyoAPI
To query your customer data using Klaviyo's APIs, you will need to authenticate that request with a private API key.
A Klaviyo private API key is an authentication token that developers need to pass on most API calls to show that they have the proper permission. A private API key lets developers use API requests to do many actions usually only available manually in Klaviyo (e.g. downloading data and viewing customer orders).
That's why it is critically important to treat private API keys like passwords. They should not be publicly viewable anywhere (e.g. on your github, on your website's frontend). Developers should also consider limiting access to these keys internally in the same way that they would limit who has access to an account password.
Klaviyo accounts do not start with a private API key, they have to be generated. You can learn about how to generate a Klaviyo private API key on our Help Center.
To run any of the API requests in this guide, you will need a private API key. For HTTP requests, this private API key is passed as an Authorization header. For SDK requests, the private key is part of the information needed to define a SDK client object.
To execute the code snippets in this notebook, please replace the private API key placeholder with your account's key.
# TODO: Update private_key
private_key = 'PRIVATE_API_KEY'
# NOTE: This key cannot exist in a public place. Do not push a script publicly with this key in it.
Now that we have imported the SDK and set an account's private API key, we next have to instantiate an SDK client. This SDK client is an intermediary between you and Klaviyo's APIs that will make your life easier.
An SDK client is necessary to run most of the examples covered in this guide.
Once this has been run, you will be able to make API requests simply by running the client object's methods.
# Instantiate the SDK client with your private API key
klaviyo = KlaviyoAPI(private_key, max_delay=5, max_retries=3)
The HTML
code snippet below has nothing to do with Klaviyo's APIs. It simply makes the notebook render better on NBViewer.
%%html
<style>
.nbviewer div.output_area {
overflow-y: auto;
max-height: 500px; /* or value of your choosing */
}
</style>
Now that we've created an SDK client authorized with your Klaviyo private API key, it's time to explore your data.
Getting your account's customer profiles is a great way to get introduced to Klaviyo's data model. We will show how to make that call both through Klaviyo's SDK and through a direct HTTP request. Both methods lead to the same result.
As a reminder, Klaviyo recommends you scope new functionality with a sandbox account filled with sample data.
The code block below shows how to do this API call using Klaviyo's SDK. It leads to the same results as a HTTP example below.
# NOTE: Does not include pagination (see Example 3.2); so, will not return all customers.
output = klaviyo.Profiles.get_profiles()
output
{'data': [{'type': 'profile', 'id': '01G111X7K5VMWZR03WV4MHRDAV', 'attributes': {'email': 'kristina.stephens_138@klaviyo-demo.com', 'phone_number': '+18409121959', 'external_id': None, 'anonymous_id': None, 'first_name': 'Kristina', 'last_name': 'Stephens', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:10+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '18335', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/segments/'}}}}, {'type': 'profile', 'id': '01G111X7VE1V41ZM36X2NKV02F', 'attributes': {'email': 'julia.dixon_222@klaviyo-demo.com', 'phone_number': '+18470101517', 'external_id': None, 'anonymous_id': None, 'first_name': 'Julia', 'last_name': 'Dixon', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80623', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/segments/'}}}}, {'type': 'profile', 'id': '01G111X7Y9WNVPZVY1BPZC5Q7Z', 'attributes': {'email': 'marsha.porter_596@klaviyo-demo.com', 'phone_number': '+14409121807', 'external_id': None, 'anonymous_id': None, 'first_name': 'Marsha', 'last_name': 'Porter', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '81576', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/segments/'}}}}, {'type': 'profile', 'id': '01G111X811JG59BMHDE8QZ2KEG', 'attributes': {'email': 'tara.wagner_206@klaviyo-demo.com', 'phone_number': '+17700006465', 'external_id': None, 'anonymous_id': None, 'first_name': 'Tara', 'last_name': 'Wagner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '24981', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/segments/'}}}}, {'type': 'profile', 'id': '01G111X83YE7FXWD8GDFBB8NVE', 'attributes': {'email': 'jack.medina_603@klaviyo-demo.com', 'phone_number': '+17235667680', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jack', 'last_name': 'Medina', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '49784', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/segments/'}}}}, {'type': 'profile', 'id': '01G111X86STXA6NYTJ3GJJRD00', 'attributes': {'email': 'devon.ortiz_362@klaviyo-demo.com', 'phone_number': '+16032688420', 'external_id': None, 'anonymous_id': None, 'first_name': 'Devon', 'last_name': 'Ortiz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '17133', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/segments/'}}}}, {'type': 'profile', 'id': '01G111X8A4KXWMXZX564EYDAMM', 'attributes': {'email': 'elizabeth.holland_998@klaviyo-demo.com', 'phone_number': '+16772197540', 'external_id': None, 'anonymous_id': None, 'first_name': 'Elizabeth', 'last_name': 'Holland', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '19422', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/segments/'}}}}, {'type': 'profile', 'id': '01G111X8D0W3H7FAF3DH7K6M5Z', 'attributes': {'email': 'gregory.rice_105@klaviyo-demo.com', 'phone_number': '+17053390984', 'external_id': None, 'anonymous_id': None, 'first_name': 'Gregory', 'last_name': 'Rice', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '53670', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/segments/'}}}}, {'type': 'profile', 'id': '01G111X8FV7W8EQCTNAC04K7TP', 'attributes': {'email': 'sheila.berry_441@klaviyo-demo.com', 'phone_number': '+11052899276', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sheila', 'last_name': 'Berry', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '15923', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/segments/'}}}}, {'type': 'profile', 'id': '01G111X8JG0B39ARRJPN3NJ893', 'attributes': {'email': 'terrence.jennings_421@klaviyo-demo.com', 'phone_number': '+11232100105', 'external_id': None, 'anonymous_id': None, 'first_name': 'Terrence', 'last_name': 'Jennings', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '43114', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/segments/'}}}}, {'type': 'profile', 'id': '01G111X8N9FG81M2Z90NMTMZTT', 'attributes': {'email': 'gerald.harvey_101@klaviyo-demo.com', 'phone_number': '(539)-331-2511', 'external_id': None, 'anonymous_id': None, 'first_name': 'Gerald', 'last_name': 'Harvey', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Hampton', 'country': None, 'latitude': None, 'longitude': None, 'region': 'South Dakota', 'zip': '38475', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/segments/'}}}}, {'type': 'profile', 'id': '01G111X8QXRWDW2H56R3V9MVPN', 'attributes': {'email': 'sherri.bryant_592@klaviyo-demo.com', 'phone_number': '+14383706640', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sherri', 'last_name': 'Bryant', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '62723', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/segments/'}}}}, {'type': 'profile', 'id': '01G111X8TQYQ8GK86BSV7F3516', 'attributes': {'email': 'sylvia.diaz_301@klaviyo-demo.com', 'phone_number': '+18807279925', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sylvia', 'last_name': 'Diaz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '72141', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/segments/'}}}}, {'type': 'profile', 'id': '01G111X8XGBB1HVJ2MQ6SF6YAY', 'attributes': {'email': 'yvonne.sullivan_716@klaviyo-demo.com', 'phone_number': '+19905230491', 'external_id': None, 'anonymous_id': None, 'first_name': 'Yvonne', 'last_name': 'Sullivan', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '10158', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/segments/'}}}}, {'type': 'profile', 'id': '01G111X9093JDHA07DDM41YKHR', 'attributes': {'email': 'micheal.simmmons_513@klaviyo-demo.com', 'phone_number': '+14474215178', 'external_id': None, 'anonymous_id': None, 'first_name': 'Micheal', 'last_name': 'Simmmons', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '37232', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/segments/'}}}}, {'type': 'profile', 'id': '01G111X934EGZPT9QXG2E66M6C', 'attributes': {'email': 'martha.turner_923@klaviyo-demo.com', 'phone_number': '+10081188694', 'external_id': None, 'anonymous_id': None, 'first_name': 'Martha', 'last_name': 'Turner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '24648', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/segments/'}}}}, {'type': 'profile', 'id': '01G111X963313P874JREC48G4Y', 'attributes': {'email': 'kenneth.daniels_954@klaviyo-demo.com', 'phone_number': '+15363857084', 'external_id': None, 'anonymous_id': None, 'first_name': 'Kenneth', 'last_name': 'Daniels', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80253', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/segments/'}}}}, {'type': 'profile', 'id': '01G111X98XVAF6RQZ46BBS7TED', 'attributes': {'email': 'catherine.sullivan_289@klaviyo-demo.com', 'phone_number': '+16175558793', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Warner-Black', 'title': 'Public relations account executive', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '49955 Joshua Springs', 'address2': 'Apt. 014', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '68533', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/segments/'}}}}, {'type': 'profile', 'id': '01G111X9BZAK6J8A67H7M871CW', 'attributes': {'email': 'tiffany.wyatt_817@klaviyo-demo.com', 'phone_number': '+16175559960', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Arnold and Sons', 'title': 'Hospital pharmacist', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '739 Bishop Mountains', 'address2': 'Apt. 785', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '86148', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/segments/'}}}}, {'type': 'profile', 'id': '01G111X9EV7DJSCR048H7KWT57', 'attributes': {'email': 'willie.hammond_555@klaviyo-demo.com', 'phone_number': '+16175551539', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Reed Group', 'title': 'Tax adviser', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '41059 Gonzalez Light', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '04505', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/segments/'}}}}], 'links': {'self': 'https://a.klaviyo.com/api/profiles/', 'next': 'https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6OjAxRzExMVg5RVY3REpTQ1IwNDhIN0tXVDU3', 'prev': None}}
The code block below shows how to accomplish this API call using a direct HTTP request. It leads to the same results as a SDK example above.
If you want to see more simple HTTP code snippets, you should look through Klaviyo's API documentation. It has examples of how to make direct API calls on each of Klaviyo's endpoints in a number of frameworks including JavaScript
, Node
, Python
, Java
, PHP
, and Shell
among others.
# NOTE: Does not include pagination (see Example 3.2); so, will not return all customers.
# The headers for a direct call on the endpoint should look similar to this (with an updated revision date)
headers = {
"accept": "application/json",
"revision": "2022-10-17",
"Authorization": "Klaviyo-API-Key " + private_key
}
# specify the endpoint you want to hit
url = "https://a.klaviyo.com/api/profiles/"
# execute the request
response = requests.request("GET",
url,
headers=headers)
# convert json string to dictionary
response_dict = json.loads(response.text)
response_dict
{'data': [{'type': 'profile', 'id': '01G111X7K5VMWZR03WV4MHRDAV', 'attributes': {'email': 'kristina.stephens_138@klaviyo-demo.com', 'phone_number': '+18409121959', 'external_id': None, 'anonymous_id': None, 'first_name': 'Kristina', 'last_name': 'Stephens', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:10+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '18335', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/segments/'}}}}, {'type': 'profile', 'id': '01G111X7VE1V41ZM36X2NKV02F', 'attributes': {'email': 'julia.dixon_222@klaviyo-demo.com', 'phone_number': '+18470101517', 'external_id': None, 'anonymous_id': None, 'first_name': 'Julia', 'last_name': 'Dixon', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80623', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/segments/'}}}}, {'type': 'profile', 'id': '01G111X7Y9WNVPZVY1BPZC5Q7Z', 'attributes': {'email': 'marsha.porter_596@klaviyo-demo.com', 'phone_number': '+14409121807', 'external_id': None, 'anonymous_id': None, 'first_name': 'Marsha', 'last_name': 'Porter', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '81576', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/segments/'}}}}, {'type': 'profile', 'id': '01G111X811JG59BMHDE8QZ2KEG', 'attributes': {'email': 'tara.wagner_206@klaviyo-demo.com', 'phone_number': '+17700006465', 'external_id': None, 'anonymous_id': None, 'first_name': 'Tara', 'last_name': 'Wagner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '24981', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/segments/'}}}}, {'type': 'profile', 'id': '01G111X83YE7FXWD8GDFBB8NVE', 'attributes': {'email': 'jack.medina_603@klaviyo-demo.com', 'phone_number': '+17235667680', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jack', 'last_name': 'Medina', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '49784', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/segments/'}}}}, {'type': 'profile', 'id': '01G111X86STXA6NYTJ3GJJRD00', 'attributes': {'email': 'devon.ortiz_362@klaviyo-demo.com', 'phone_number': '+16032688420', 'external_id': None, 'anonymous_id': None, 'first_name': 'Devon', 'last_name': 'Ortiz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '17133', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/segments/'}}}}, {'type': 'profile', 'id': '01G111X8A4KXWMXZX564EYDAMM', 'attributes': {'email': 'elizabeth.holland_998@klaviyo-demo.com', 'phone_number': '+16772197540', 'external_id': None, 'anonymous_id': None, 'first_name': 'Elizabeth', 'last_name': 'Holland', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '19422', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/segments/'}}}}, {'type': 'profile', 'id': '01G111X8D0W3H7FAF3DH7K6M5Z', 'attributes': {'email': 'gregory.rice_105@klaviyo-demo.com', 'phone_number': '+17053390984', 'external_id': None, 'anonymous_id': None, 'first_name': 'Gregory', 'last_name': 'Rice', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '53670', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/segments/'}}}}, {'type': 'profile', 'id': '01G111X8FV7W8EQCTNAC04K7TP', 'attributes': {'email': 'sheila.berry_441@klaviyo-demo.com', 'phone_number': '+11052899276', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sheila', 'last_name': 'Berry', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '15923', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/segments/'}}}}, {'type': 'profile', 'id': '01G111X8JG0B39ARRJPN3NJ893', 'attributes': {'email': 'terrence.jennings_421@klaviyo-demo.com', 'phone_number': '+11232100105', 'external_id': None, 'anonymous_id': None, 'first_name': 'Terrence', 'last_name': 'Jennings', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '43114', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/segments/'}}}}, {'type': 'profile', 'id': '01G111X8N9FG81M2Z90NMTMZTT', 'attributes': {'email': 'gerald.harvey_101@klaviyo-demo.com', 'phone_number': '(539)-331-2511', 'external_id': None, 'anonymous_id': None, 'first_name': 'Gerald', 'last_name': 'Harvey', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Hampton', 'country': None, 'latitude': None, 'longitude': None, 'region': 'South Dakota', 'zip': '38475', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/segments/'}}}}, {'type': 'profile', 'id': '01G111X8QXRWDW2H56R3V9MVPN', 'attributes': {'email': 'sherri.bryant_592@klaviyo-demo.com', 'phone_number': '+14383706640', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sherri', 'last_name': 'Bryant', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '62723', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/segments/'}}}}, {'type': 'profile', 'id': '01G111X8TQYQ8GK86BSV7F3516', 'attributes': {'email': 'sylvia.diaz_301@klaviyo-demo.com', 'phone_number': '+18807279925', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sylvia', 'last_name': 'Diaz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '72141', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/segments/'}}}}, {'type': 'profile', 'id': '01G111X8XGBB1HVJ2MQ6SF6YAY', 'attributes': {'email': 'yvonne.sullivan_716@klaviyo-demo.com', 'phone_number': '+19905230491', 'external_id': None, 'anonymous_id': None, 'first_name': 'Yvonne', 'last_name': 'Sullivan', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '10158', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/segments/'}}}}, {'type': 'profile', 'id': '01G111X9093JDHA07DDM41YKHR', 'attributes': {'email': 'micheal.simmmons_513@klaviyo-demo.com', 'phone_number': '+14474215178', 'external_id': None, 'anonymous_id': None, 'first_name': 'Micheal', 'last_name': 'Simmmons', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '37232', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/segments/'}}}}, {'type': 'profile', 'id': '01G111X934EGZPT9QXG2E66M6C', 'attributes': {'email': 'martha.turner_923@klaviyo-demo.com', 'phone_number': '+10081188694', 'external_id': None, 'anonymous_id': None, 'first_name': 'Martha', 'last_name': 'Turner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '24648', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/segments/'}}}}, {'type': 'profile', 'id': '01G111X963313P874JREC48G4Y', 'attributes': {'email': 'kenneth.daniels_954@klaviyo-demo.com', 'phone_number': '+15363857084', 'external_id': None, 'anonymous_id': None, 'first_name': 'Kenneth', 'last_name': 'Daniels', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80253', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/segments/'}}}}, {'type': 'profile', 'id': '01G111X98XVAF6RQZ46BBS7TED', 'attributes': {'email': 'catherine.sullivan_289@klaviyo-demo.com', 'phone_number': '+16175558793', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Warner-Black', 'title': 'Public relations account executive', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '49955 Joshua Springs', 'address2': 'Apt. 014', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '68533', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/segments/'}}}}, {'type': 'profile', 'id': '01G111X9BZAK6J8A67H7M871CW', 'attributes': {'email': 'tiffany.wyatt_817@klaviyo-demo.com', 'phone_number': '+16175559960', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Arnold and Sons', 'title': 'Hospital pharmacist', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '739 Bishop Mountains', 'address2': 'Apt. 785', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '86148', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/segments/'}}}}, {'type': 'profile', 'id': '01G111X9EV7DJSCR048H7KWT57', 'attributes': {'email': 'willie.hammond_555@klaviyo-demo.com', 'phone_number': '+16175551539', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Reed Group', 'title': 'Tax adviser', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '41059 Gonzalez Light', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '04505', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/segments/'}}}}], 'links': {'self': 'https://a.klaviyo.com/api/profiles/', 'next': 'https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6OjAxRzExMVg5RVY3REpTQ1IwNDhIN0tXVDU3', 'prev': None}}
As you can see, the data is returned in a nested dictionary format (i.e. a JSON). The core information that we requested for this call lives in the data
field.
The data
field can take different forms depending on the data being queried. For example, the data
field can map to a dictionary or a list of dictionaries depending on whether you are querying a single record or many.
Klaviyo's response for a GET request returning multiple records has the following form:
# response dictionary
{
'data': [
record_dict_1,
record_dict_2,
...,
record_dict_n
],
'links': {
... # links not shown. Explained further in Example 4.2
}
}
The content and schema of these record dicts depend on the data being requested. Regardless of the data queried, all Klaviyo API responses should follow the form shown above with a data
field containing the content of the request and a links
field containing pagination metadata.
Now that we have a better understanding of how API responses are structured generally, let's take a look at how the record_dicts
can be structured.
The data
field in an API response maps to a dictionary or list of dictionaries. The content and schema for the dicts themselves is dependent on the type of record being requested.
Let's take a look at how customer profile dicts are structured since they are the subject of this Hello World example. The core information about a customer account exists in the attributes
field.
# this is the schema for data on an individual customer profile
{
"type": "profile",
"id": "string",
"attributes": {
"email": "string",
"phone_number": "string",
"external_id": "string",
"anonymous_id": "string",
"first_name": "string",
"last_name": "string",
"organization": "string",
"title": "string",
"image": "string",
"created": "string (UTC-formatted datetime)",
"updated": "string (UTC-formatted datetime)",
"last_event_date": "string (UTC-formatted datetime)",
"location": {
"address1": "string",
"address2": "string",
"city": "string",
"country": "string",
"latitude": "string",
"longitude": "string",
"region": "string",
"zip": "string",
"timezone": "string"
},
"properties": {} # holds any custom attributes
},
... # links and relationships not shown
}
Profiles in Klaviyo's database contain core attributes about these customers (e.g. address, name, communication methods) as well as unique profiles identifiers. One such identifier is a profile's Klaviyo ID, which shows up under the id
field as a 26 character string.
If you have questions about how events or profiles are structured or what field names refer to, please consult Klaviyo's API documentation
Events and profiles have each been mentioned throughout this guide. Let's clarify what these terms mean.
A customer profile is a set of information unique to each of the customers of your business. Events are things that happen related to these customers (e.g. product orders or email delivery).
These events usually have data describing the specifics of what happened. For example, an Ordered Product event captures information about the product price, product name, time of purchase, among other information.
Each event is associated with a single customer profile. Profiles, however, can be associated with many events.
You can learn more about customer profiles, events, and metrics from Klaviyo's help center.
Customer events can be viewed in Klaviyo or retrieved with an API call. To make this more clear, below is a screenshot showing a single customer's timeline of events:
The Hello World section covered how to pull customer account data generally. But now let's say you want information on a single customer account. This can be done with a call to Klaviyo's SDK.
To make that call, though, we would need the customer profile's Klaviyo ID.
Each customer profile in your account has a Klaviyo ID assigned to it. This is a unique identifier managed by Klaviyo, which can be used to identify customer profiles. In Klaviyo's API responses, a profile's Klaviyo ID shows up under the id
field. You can use an account's Klaviyo ID to identify customer profile
External IDs, on the other hand, are managed by you, and not Klaviyo. Customer profiles do not automatically start with an external ID. You can use the external ID field to hold string identifiers of up to 64 characters. A profile's external ID shows up under the external_id
field.
The /profiles
endpoint expects a Klaviyo ID to identify customer profiles.
You can get a profile's Klaviyo ID from within Klaviyo or from the id
field returned by Klaviyo's APIs (shown in the schema above).
Let's take a closer look at how to get that same information in Klaviyo.
Step 1: Go into your Klaviyo account and select the Profiles tab. Click on a customer you want to pull data on.
Step 2: The selected profile will have a profile_id embedded into the URL. This will show up as either a 6-character or 26-character long, alphanumeric string.
Find a customer account with event history and copy and paste their Klaviyo ID into the profile_id
variable below.
# TODO: replace this with your own id
profile_id = 'YOUR-PROFILE-ID'
klaviyo.Profiles.get_profile(profile_id)
{'data': {'type': 'profile', 'id': '01G7EZ8ZFYS7TMG76M24JEV64T', 'attributes': {'email': 'henry.downing@klaviyo-demo.com', 'phone_number': None, 'external_id': None, 'anonymous_id': None, 'first_name': 'Henry', 'last_name': 'Downing (Sample)', 'organization': 'Klaviyo', 'title': 'developer', 'image': None, 'created': '2022-07-08T13:16:37+00:00', 'updated': '2022-07-08T13:16:38+00:00', 'last_event_date': '2022-07-08T13:16:38+00:00', 'location': {'address1': '225 Franklin St', 'address2': '6th floor', 'city': 'Boston', 'country': 'USA', 'latitude': None, 'longitude': None, 'region': 'MA', 'zip': '02111', 'timezone': None}, 'properties': {'$latitude': '42.3559', '$longitude': '71.0537', 'klaviyo_sample_data_gen': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G7EZ8ZFYS7TMG76M24JEV64T/'}, 'relationships': {'lists': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G7EZ8ZFYS7TMG76M24JEV64T/relationships/lists/', 'related': 'https://a.klaviyo.com/api/profiles/01G7EZ8ZFYS7TMG76M24JEV64T/lists/'}}, 'segments': {'links': {'self': 'https://a.klaviyo.com/api/profiles/01G7EZ8ZFYS7TMG76M24JEV64T/relationships/segments/', 'related': 'https://a.klaviyo.com/api/profiles/01G7EZ8ZFYS7TMG76M24JEV64T/segments/'}}}}}
By calling klaviyo.Profiles.get_profile()
with a specific profile's Klaviyo ID, we were able to successfully pull that customer's account information. Note how the API response and customer profile schema follow the pattern described in the Hello World section.
Klaviyo's help center has a more thorough article covering how customer profiles are structured
Lists & Segments are a core part of Klaviyo. Lists are generally static groupings of profiles while segments are dynamically updated based on customer attributes. New developers can explore how Lists & Segments work in Klaviyo in our help center article.
Companies using Klaviyo often need to pull customer accounts belonging to a given list or segment. Let's see how you can do this programmatically with Klaviyo's APIs.
A list ID or segment ID is a six digit, alphanumeric string used to uniquely identify the given list or segment. The process for getting one of these identifiers is similar to the process of getting a Klaviyo ID.
You can either get this manually in Klaviyo or programmatically with Klaviyo's APIs. To keep this guide brief, these methods are not repeated.
Now that we've identified the target list, the next step is another SDK one-liner to grab the profiles in the list.
# TODO: Update with your list_id
list_id = 'YOUR-LIST-ID'
# Note: Pagination not implemented (see below)
response_dict = klaviyo.Lists.get_list_profiles(list_id)
# print(response)
print('length of results', len(response_dict['data']))
# display output
response_dict
length of results 10
{'data': [{'type': 'profile', 'id': '01G111X7K5VMWZR03WV4MHRDAV', 'attributes': {'email': 'kristina.stephens_138@klaviyo-demo.com', 'phone_number': '+18409121959', 'external_id': None, 'anonymous_id': None, 'first_name': 'Kristina', 'last_name': 'Stephens', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:10+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '18335', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/'}}, {'type': 'profile', 'id': '01G111X7VE1V41ZM36X2NKV02F', 'attributes': {'email': 'julia.dixon_222@klaviyo-demo.com', 'phone_number': '+18470101517', 'external_id': None, 'anonymous_id': None, 'first_name': 'Julia', 'last_name': 'Dixon', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80623', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/'}}, {'type': 'profile', 'id': '01G111X7Y9WNVPZVY1BPZC5Q7Z', 'attributes': {'email': 'marsha.porter_596@klaviyo-demo.com', 'phone_number': '+14409121807', 'external_id': None, 'anonymous_id': None, 'first_name': 'Marsha', 'last_name': 'Porter', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '81576', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/'}}, {'type': 'profile', 'id': '01G111X811JG59BMHDE8QZ2KEG', 'attributes': {'email': 'tara.wagner_206@klaviyo-demo.com', 'phone_number': '+17700006465', 'external_id': None, 'anonymous_id': None, 'first_name': 'Tara', 'last_name': 'Wagner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '24981', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/'}}, {'type': 'profile', 'id': '01G111X83YE7FXWD8GDFBB8NVE', 'attributes': {'email': 'jack.medina_603@klaviyo-demo.com', 'phone_number': '+17235667680', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jack', 'last_name': 'Medina', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '49784', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/'}}, {'type': 'profile', 'id': '01G111X86STXA6NYTJ3GJJRD00', 'attributes': {'email': 'devon.ortiz_362@klaviyo-demo.com', 'phone_number': '+16032688420', 'external_id': None, 'anonymous_id': None, 'first_name': 'Devon', 'last_name': 'Ortiz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '17133', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/'}}, {'type': 'profile', 'id': '01G111X8A4KXWMXZX564EYDAMM', 'attributes': {'email': 'elizabeth.holland_998@klaviyo-demo.com', 'phone_number': '+16772197540', 'external_id': None, 'anonymous_id': None, 'first_name': 'Elizabeth', 'last_name': 'Holland', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '19422', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/'}}, {'type': 'profile', 'id': '01G111X8D0W3H7FAF3DH7K6M5Z', 'attributes': {'email': 'gregory.rice_105@klaviyo-demo.com', 'phone_number': '+17053390984', 'external_id': None, 'anonymous_id': None, 'first_name': 'Gregory', 'last_name': 'Rice', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '53670', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/'}}, {'type': 'profile', 'id': '01G111X8FV7W8EQCTNAC04K7TP', 'attributes': {'email': 'sheila.berry_441@klaviyo-demo.com', 'phone_number': '+11052899276', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sheila', 'last_name': 'Berry', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '15923', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/'}}, {'type': 'profile', 'id': '01G111X8JG0B39ARRJPN3NJ893', 'attributes': {'email': 'terrence.jennings_421@klaviyo-demo.com', 'phone_number': '+11232100105', 'external_id': None, 'anonymous_id': None, 'first_name': 'Terrence', 'last_name': 'Jennings', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '43114', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/'}}], 'links': {'self': 'https://a.klaviyo.com/api/lists/Sci6CL/profiles/', 'next': 'https://a.klaviyo.com/api/lists/Sci6CL/profiles/?page%5Bcursor%5D=bmV4dDo6MDFHMTExWDhKRzBCMzlBUlJKUE4zTko4OTM', 'prev': None}}
The list used in the example above has 100 profiles in it. However, the API only returned 10 profiles. Why don't all the profiles show up?
This is a common question that new developers run into.
When you query many records at once using Klaviyo's APIs -- for example, querying a large list -- the results are returned in small chunks rather than all at once. To see all the profiles in the list, you have to iterate over the pages of your query's results. This process is called pagination.
Pagination is an important feature of Klaviyo's APIs meant to lower response times, reduce errors, and protect accounts from running into rate limit issues.
Klaviyo API responses natively return information in the links
argument to make the process of pagination easier. This is best seen through example.
Standard in all Klaviyo API returns is the links
argument, which has the following form:
response = {'data': {...},
...,
'links': {
'self': URL_STRING,
'next': URL_STRING or NoneType,
'previous': URL_STRING or NoneType
}
}
This links
key maps to the information you will need to execute pagination.
Specifically, if you are trying to access 100 records, 10 records at a time, it would look like the following:
# Page 1 of results (original GET request)
'links': {
'self': URL_STRING_1_to_10,
'next': URL_STRING_11_to_20,
'previous': None
}
# Page 2 of results (GET request on URL_STRING_11_to_20)
'links': {
'self': URL_STRING_11_to_20,
'next': URL_STRING_21_to_30,
'previous': URL_STRING_1_to_10
}
... # Pages [3,4,5,6,7,8,9]
# Page 10 of results (GET request on URL_STRING_91_to_100)
'links': {
'self': URL_STRING_91_to_100,
'next': None,
'previous': URL_STRING_81_to_90
}
Therefore, pagination can be succinctly expressed as a while loop searching for when response['links']['next'] is None
.
If you are interacting with Klaviyo's endpoint directly through HTTP, you can simply make a GET
request on the URL strings returned in the links
argument.
If you are using Klaviyo's Python
or PHP
SDK, you can take the URL string returned and pass it directly to the SDK's page_cursor argument.
However, if you are using an SDK in Node
or Ruby
, then there is an extra step involved. You will need to parse the URL string to grab the page cursor embedded in the URL.
Note that URL_STRINGs
provided by the links
argument have any of the following formats:
https://a.klaviyo.com/.../endpoint/?page%5Bcursor%5D=PAGE_CURSOR_ID
https://a.klaviyo.com/.../endpoint/?filter=...&page%5Bcursor%5D=PAGE_CURSOR_ID
https://a.klaviyo.com/.../endpoint/?filter=...&page%5Bcursor%5D=PAGE_CURSOR_ID&sort=...
So, a helper function to parse PAGE_CURSOR_ID
from any of those strings (in Python) could look like the following:
def get_page_cursor_from_url(next_url):
page_cursor = next_url.split('cursor%5D=')[1].split('&')[0]
return page_cursor
Now all those logistics are out of the way, let's see how we can execute a while loop to get all the data that our API request applies to.
Note that if you are querying a very large amount of data, you should be aware that Klaviyo's APIs have rate limits. Built into Klaviyo's SDK instantiation is customizable retry logic, which should help developers avoid 429 errors in most cases.
results_list = []
# TODO: Update with your list_id
list_id = 'YOUR-LIST-ID'
response = klaviyo.Lists.get_list_profiles(list_id)
results_list.extend(response['data'])
next_url = response['links']['next']
while next_url is not None:
response = klaviyo.Lists.get_list_profiles(list_id, page_cursor=next_url)
results_list.extend(response['data'])
next_url = response['links']['next']
print('length of results', len(results_list))
print(results_list)
length of results 100 [{'type': 'profile', 'id': '01G111X7K5VMWZR03WV4MHRDAV', 'attributes': {'email': 'kristina.stephens_138@klaviyo-demo.com', 'phone_number': '+18409121959', 'external_id': None, 'anonymous_id': None, 'first_name': 'Kristina', 'last_name': 'Stephens', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:10+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '18335', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7K5VMWZR03WV4MHRDAV/'}}, {'type': 'profile', 'id': '01G111X7VE1V41ZM36X2NKV02F', 'attributes': {'email': 'julia.dixon_222@klaviyo-demo.com', 'phone_number': '+18470101517', 'external_id': None, 'anonymous_id': None, 'first_name': 'Julia', 'last_name': 'Dixon', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80623', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7VE1V41ZM36X2NKV02F/'}}, {'type': 'profile', 'id': '01G111X7Y9WNVPZVY1BPZC5Q7Z', 'attributes': {'email': 'marsha.porter_596@klaviyo-demo.com', 'phone_number': '+14409121807', 'external_id': None, 'anonymous_id': None, 'first_name': 'Marsha', 'last_name': 'Porter', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '81576', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X7Y9WNVPZVY1BPZC5Q7Z/'}}, {'type': 'profile', 'id': '01G111X811JG59BMHDE8QZ2KEG', 'attributes': {'email': 'tara.wagner_206@klaviyo-demo.com', 'phone_number': '+17700006465', 'external_id': None, 'anonymous_id': None, 'first_name': 'Tara', 'last_name': 'Wagner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '24981', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X811JG59BMHDE8QZ2KEG/'}}, {'type': 'profile', 'id': '01G111X83YE7FXWD8GDFBB8NVE', 'attributes': {'email': 'jack.medina_603@klaviyo-demo.com', 'phone_number': '+17235667680', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jack', 'last_name': 'Medina', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '49784', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X83YE7FXWD8GDFBB8NVE/'}}, {'type': 'profile', 'id': '01G111X86STXA6NYTJ3GJJRD00', 'attributes': {'email': 'devon.ortiz_362@klaviyo-demo.com', 'phone_number': '+16032688420', 'external_id': None, 'anonymous_id': None, 'first_name': 'Devon', 'last_name': 'Ortiz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '17133', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X86STXA6NYTJ3GJJRD00/'}}, {'type': 'profile', 'id': '01G111X8A4KXWMXZX564EYDAMM', 'attributes': {'email': 'elizabeth.holland_998@klaviyo-demo.com', 'phone_number': '+16772197540', 'external_id': None, 'anonymous_id': None, 'first_name': 'Elizabeth', 'last_name': 'Holland', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '19422', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8A4KXWMXZX564EYDAMM/'}}, {'type': 'profile', 'id': '01G111X8D0W3H7FAF3DH7K6M5Z', 'attributes': {'email': 'gregory.rice_105@klaviyo-demo.com', 'phone_number': '+17053390984', 'external_id': None, 'anonymous_id': None, 'first_name': 'Gregory', 'last_name': 'Rice', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '53670', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8D0W3H7FAF3DH7K6M5Z/'}}, {'type': 'profile', 'id': '01G111X8FV7W8EQCTNAC04K7TP', 'attributes': {'email': 'sheila.berry_441@klaviyo-demo.com', 'phone_number': '+11052899276', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sheila', 'last_name': 'Berry', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:05+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '15923', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8FV7W8EQCTNAC04K7TP/'}}, {'type': 'profile', 'id': '01G111X8JG0B39ARRJPN3NJ893', 'attributes': {'email': 'terrence.jennings_421@klaviyo-demo.com', 'phone_number': '+11232100105', 'external_id': None, 'anonymous_id': None, 'first_name': 'Terrence', 'last_name': 'Jennings', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '43114', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8JG0B39ARRJPN3NJ893/'}}, {'type': 'profile', 'id': '01G111X8N9FG81M2Z90NMTMZTT', 'attributes': {'email': 'gerald.harvey_101@klaviyo-demo.com', 'phone_number': '(539)-331-2511', 'external_id': None, 'anonymous_id': None, 'first_name': 'Gerald', 'last_name': 'Harvey', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Hampton', 'country': None, 'latitude': None, 'longitude': None, 'region': 'South Dakota', 'zip': '38475', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8N9FG81M2Z90NMTMZTT/'}}, {'type': 'profile', 'id': '01G111X8QXRWDW2H56R3V9MVPN', 'attributes': {'email': 'sherri.bryant_592@klaviyo-demo.com', 'phone_number': '+14383706640', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sherri', 'last_name': 'Bryant', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '62723', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8QXRWDW2H56R3V9MVPN/'}}, {'type': 'profile', 'id': '01G111X8TQYQ8GK86BSV7F3516', 'attributes': {'email': 'sylvia.diaz_301@klaviyo-demo.com', 'phone_number': '+18807279925', 'external_id': None, 'anonymous_id': None, 'first_name': 'Sylvia', 'last_name': 'Diaz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '72141', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8TQYQ8GK86BSV7F3516/'}}, {'type': 'profile', 'id': '01G111X8XGBB1HVJ2MQ6SF6YAY', 'attributes': {'email': 'yvonne.sullivan_716@klaviyo-demo.com', 'phone_number': '+19905230491', 'external_id': None, 'anonymous_id': None, 'first_name': 'Yvonne', 'last_name': 'Sullivan', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '10158', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X8XGBB1HVJ2MQ6SF6YAY/'}}, {'type': 'profile', 'id': '01G111X9093JDHA07DDM41YKHR', 'attributes': {'email': 'micheal.simmmons_513@klaviyo-demo.com', 'phone_number': '+14474215178', 'external_id': None, 'anonymous_id': None, 'first_name': 'Micheal', 'last_name': 'Simmmons', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '37232', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9093JDHA07DDM41YKHR/'}}, {'type': 'profile', 'id': '01G111X934EGZPT9QXG2E66M6C', 'attributes': {'email': 'martha.turner_923@klaviyo-demo.com', 'phone_number': '+10081188694', 'external_id': None, 'anonymous_id': None, 'first_name': 'Martha', 'last_name': 'Turner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '24648', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X934EGZPT9QXG2E66M6C/'}}, {'type': 'profile', 'id': '01G111X963313P874JREC48G4Y', 'attributes': {'email': 'kenneth.daniels_954@klaviyo-demo.com', 'phone_number': '+15363857084', 'external_id': None, 'anonymous_id': None, 'first_name': 'Kenneth', 'last_name': 'Daniels', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80253', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X963313P874JREC48G4Y/'}}, {'type': 'profile', 'id': '01G111X98XVAF6RQZ46BBS7TED', 'attributes': {'email': 'catherine.sullivan_289@klaviyo-demo.com', 'phone_number': '+16175558793', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Warner-Black', 'title': 'Public relations account executive', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '49955 Joshua Springs', 'address2': 'Apt. 014', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '68533', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X98XVAF6RQZ46BBS7TED/'}}, {'type': 'profile', 'id': '01G111X9BZAK6J8A67H7M871CW', 'attributes': {'email': 'tiffany.wyatt_817@klaviyo-demo.com', 'phone_number': '+16175559960', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Arnold and Sons', 'title': 'Hospital pharmacist', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '739 Bishop Mountains', 'address2': 'Apt. 785', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '86148', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9BZAK6J8A67H7M871CW/'}}, {'type': 'profile', 'id': '01G111X9EV7DJSCR048H7KWT57', 'attributes': {'email': 'willie.hammond_555@klaviyo-demo.com', 'phone_number': '+16175551539', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Reed Group', 'title': 'Tax adviser', 'image': None, 'created': '2022-04-19T13:59:06+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '41059 Gonzalez Light', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '04505', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9EV7DJSCR048H7KWT57/'}}, {'type': 'profile', 'id': '01G111X9HN1BKDFRZDJP57Z65R', 'attributes': {'email': 'allen.allen_685@klaviyo-demo.com', 'phone_number': '+16175555239', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Chaney-Tanner', 'title': 'Television floor manager', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '46471 Sanchez Summit', 'address2': 'Suite 177', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '68575', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9HN1BKDFRZDJP57Z65R/'}}, {'type': 'profile', 'id': '01G111X9MD55K8WX1ZVQ4DT64E', 'attributes': {'email': 'laura.morris_839@klaviyo-demo.com', 'phone_number': '+16175559912', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Salinas-Gutierrez', 'title': 'Engineer, mining', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '155 James Drives', 'address2': 'Apt. 904', 'city': 'Moralesfurt', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'WY', 'zip': '15509', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9MD55K8WX1ZVQ4DT64E/'}}, {'type': 'profile', 'id': '01G111X9Q9MZW2EW3B7668261W', 'attributes': {'email': 'joanne.scott_030@klaviyo-demo.com', 'phone_number': '+16175559984', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Bradford, Hall and Scott', 'title': 'Chief Operating Officer', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '461 Sandra Drives', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '46832', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9Q9MZW2EW3B7668261W/'}}, {'type': 'profile', 'id': '01G111X9T1M18VYFZERCT19AW5', 'attributes': {'email': 'gabriel.nelson_932@klaviyo-demo.com', 'phone_number': '+16175552876', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Barker-Hicks', 'title': 'Geochemist', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '42649 Karen Court', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '45470', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9T1M18VYFZERCT19AW5/'}}, {'type': 'profile', 'id': '01G111X9WT6X12B6BJVSRTQBY4', 'attributes': {'email': 'larry.bell_148@klaviyo-demo.com', 'phone_number': '+16175555099', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Simon-Sexton', 'title': 'Administrator, charities/voluntary organisations', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '5563 Henderson Fork', 'address2': 'Suite 869', 'city': 'Torresberg', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'NE', 'zip': '19668', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9WT6X12B6BJVSRTQBY4/'}}, {'type': 'profile', 'id': '01G111X9ZEYGT808N0JA17EJ2C', 'attributes': {'email': 'kristin.best_435@klaviyo-demo.com', 'phone_number': '+16175556970', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Hoover PLC', 'title': 'Broadcast journalist', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '1158 John Rue', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '60662', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111X9ZEYGT808N0JA17EJ2C/'}}, {'type': 'profile', 'id': '01G111XA2CMYVDQ05C09H6MJH8', 'attributes': {'email': 'hector.reyes_614@klaviyo-demo.com', 'phone_number': '+16175554810', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Brooks-Perez', 'title': 'Textile designer', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '392 Vega Highway', 'address2': 'Apt. 203', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '34244', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XA2CMYVDQ05C09H6MJH8/'}}, {'type': 'profile', 'id': '01G111XA56C7S2T3QZ95BNJ73B', 'attributes': {'email': 'leroy.keller_589@klaviyo-demo.com', 'phone_number': '+16175557838', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Cherry-Hernandez', 'title': 'Arts development officer', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '00917 Tara Rapids', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '71145', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XA56C7S2T3QZ95BNJ73B/'}}, {'type': 'profile', 'id': '01G111XA7ZCS53QHGW8XHMAPPS', 'attributes': {'email': 'adam.chang_572@klaviyo-demo.com', 'phone_number': '+16175554860', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Harris, Wright and Molina', 'title': 'Equality and diversity officer', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '9330 Lawrence Route', 'address2': 'Apt. 555', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '43850', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XA7ZCS53QHGW8XHMAPPS/'}}, {'type': 'profile', 'id': '01G111XAAQXNXAD1XQP06DHZBK', 'attributes': {'email': 'ruth.watkins_727@klaviyo-demo.com', 'phone_number': '+16175553297', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Massey-Castillo', 'title': 'Public librarian', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '71779 Jade Coves', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '23420', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XAAQXNXAD1XQP06DHZBK/'}}, {'type': 'profile', 'id': '01G111XADH3AD2AGD0KX4NVCW5', 'attributes': {'email': 'jeremiah.duncan_928@klaviyo-demo.com', 'phone_number': '+16175554248', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Barrett and Sons', 'title': 'Ranger/warden', 'image': None, 'created': '2022-04-19T13:59:07+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '093 Timothy Lock', 'address2': 'Apt. 401', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '64020', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XADH3AD2AGD0KX4NVCW5/'}}, {'type': 'profile', 'id': '01G111XAHDKMEQYGFN7SM9WZ3V', 'attributes': {'email': 'donna.aguilar_775@klaviyo-demo.com', 'phone_number': '+16175553087', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Cruz LLC', 'title': 'Barrister', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '8421 Nicholas Inlet', 'address2': None, 'city': 'Aprilberg', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'WV', 'zip': '58002', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XAHDKMEQYGFN7SM9WZ3V/'}}, {'type': 'profile', 'id': '01G111XAMB1FH8JM7DQT1PK3XH', 'attributes': {'email': 'erika.ross_410@klaviyo-demo.com', 'phone_number': '+16175556297', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Taylor-Marshall', 'title': 'Teacher, music', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '86636 Simpson Crescent', 'address2': None, 'city': 'Nicholsonville', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'KS', 'zip': '38323', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XAMB1FH8JM7DQT1PK3XH/'}}, {'type': 'profile', 'id': '01G111XAQ37PRGMBY6D3P1YFTH', 'attributes': {'email': 'allison.sharp_188@klaviyo-demo.com', 'phone_number': '+16175552595', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Bentley-Baker', 'title': 'Community development worker', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '6453 Chapman Row', 'address2': 'Suite 135', 'city': 'Kaitlynchester', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'NC', 'zip': '89247', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XAQ37PRGMBY6D3P1YFTH/'}}, {'type': 'profile', 'id': '01G111XAST0CSPD0BETJPHMFAG', 'attributes': {'email': 'shannon.lewis_524@klaviyo-demo.com', 'phone_number': '+16175559794', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Smith, Ramirez and Brown', 'title': 'Acupuncturist', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '81227 Clark Fort', 'address2': None, 'city': 'Lake Richardstad', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'ID', 'zip': '67974', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XAST0CSPD0BETJPHMFAG/'}}, {'type': 'profile', 'id': '01G111XAWPWFKKDY3VBHFE2715', 'attributes': {'email': 'briana.robbins_018@klaviyo-demo.com', 'phone_number': '+16175558344', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Moore, Reed and Gonzales', 'title': 'Buyer, industrial', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '58813 Steven Point', 'address2': 'Suite 187', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '36991', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XAWPWFKKDY3VBHFE2715/'}}, {'type': 'profile', 'id': '01G111XAZHXAJ32GFC8SK1CGPE', 'attributes': {'email': 'courtney.alexander_705@klaviyo-demo.com', 'phone_number': '+16175555476', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Wood, Cisneros and Alexander', 'title': 'Trade mark attorney', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '8248 Johnson Valleys', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '61289', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XAZHXAJ32GFC8SK1CGPE/'}}, {'type': 'profile', 'id': '01G111XB2F1JMBD2TKKVMPB164', 'attributes': {'email': 'mark.benton_046@klaviyo-demo.com', 'phone_number': '+16175552374', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Ward Ltd', 'title': 'Best boy', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '47075 Michael Stream', 'address2': 'Apt. 473', 'city': 'East Tinaland', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'IL', 'zip': '77818', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XB2F1JMBD2TKKVMPB164/'}}, {'type': 'profile', 'id': '01G111XB59DGX54KNHT95RTBZ7', 'attributes': {'email': 'roy.garrett_789@klaviyo-demo.com', 'phone_number': '+16175554435', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Crosby-Watts', 'title': 'Health physicist', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '71548 Oliver Road', 'address2': 'Suite 099', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '29846', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XB59DGX54KNHT95RTBZ7/'}}, {'type': 'profile', 'id': '01G111XB88DB8Q0BKZS93B5FTS', 'attributes': {'email': 'erica.mcintyre_834@klaviyo-demo.com', 'phone_number': '+16175555392', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Martinez Inc', 'title': 'Sports development officer', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '025 Thomas Vista', 'address2': 'Apt. 753', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '20711', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XB88DB8Q0BKZS93B5FTS/'}}, {'type': 'profile', 'id': '01G111XBB4S76CC3H5ST4MSRR3', 'attributes': {'email': 'natalie.wright_440@klaviyo-demo.com', 'phone_number': '+16175559928', 'external_id': None, 'anonymous_id': None, 'first_name': 'Natalie', 'last_name': 'Wright', 'organization': 'Frank-Peterson', 'title': 'Clinical psychologist', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '9003 Jeffrey Mills', 'address2': None, 'city': 'Victoriatown', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'IL', 'zip': '91290', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBB4S76CC3H5ST4MSRR3/'}}, {'type': 'profile', 'id': '01G111XBE064VARRSS964NTWC9', 'attributes': {'email': 'robert.patrick_669@klaviyo-demo.com', 'phone_number': '+16175557086', 'external_id': None, 'anonymous_id': None, 'first_name': 'Robert', 'last_name': 'Patrick', 'organization': 'Morris LLC', 'title': 'Race relations officer', 'image': None, 'created': '2022-04-19T13:59:08+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '789 Taylor Corners', 'address2': 'Suite 776', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '75392', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBE064VARRSS964NTWC9/'}}, {'type': 'profile', 'id': '01G111XBGVWQ1G1785SKAK0H57', 'attributes': {'email': 'eileen.harris_017@klaviyo-demo.com', 'phone_number': '+16175553926', 'external_id': None, 'anonymous_id': None, 'first_name': 'Eileen', 'last_name': 'Harris', 'organization': 'Rivera, Carroll and Decker', 'title': 'Financial manager', 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '282 Lauren Course', 'address2': 'Suite 385', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '93721', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBGVWQ1G1785SKAK0H57/'}}, {'type': 'profile', 'id': '01G111XBKQFKSHDJK471HVF0AP', 'attributes': {'email': 'brandon.sims_674@klaviyo-demo.com', 'phone_number': '+16175552835', 'external_id': None, 'anonymous_id': None, 'first_name': 'Brandon', 'last_name': 'Sims', 'organization': 'Frazier Inc', 'title': 'Trading standards officer', 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '72644 Amy Parkway', 'address2': None, 'city': 'Zacharyville', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'KY', 'zip': '20387', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBKQFKSHDJK471HVF0AP/'}}, {'type': 'profile', 'id': '01G111XBPK7JCHYV9Q03XXWEV0', 'attributes': {'email': 'samuel.schmitt_395@klaviyo-demo.com', 'phone_number': '1-520-732-723', 'external_id': None, 'anonymous_id': None, 'first_name': 'Samuel', 'last_name': 'Schmitt', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'North Cherylview', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Nevada', 'zip': '18795', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBPK7JCHYV9Q03XXWEV0/'}}, {'type': 'profile', 'id': '01G111XBSCFTS3ZP78NP9DEMR5', 'attributes': {'email': 'diana.robertson_352@klaviyo-demo.com', 'phone_number': '(849)-774-8574', 'external_id': None, 'anonymous_id': None, 'first_name': 'Diana', 'last_name': 'Robertson', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Raleigh', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Illinois', 'zip': '21510', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBSCFTS3ZP78NP9DEMR5/'}}, {'type': 'profile', 'id': '01G111XBW3E4NFCK13XCK6060C', 'attributes': {'email': 'marion.white_579@klaviyo-demo.com', 'phone_number': '(875)-204-6929', 'external_id': None, 'anonymous_id': None, 'first_name': 'Marion', 'last_name': 'White', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Roseburg', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Iowa', 'zip': '27481', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBW3E4NFCK13XCK6060C/'}}, {'type': 'profile', 'id': '01G111XBYYPDPDVY8ER8ZVZAVK', 'attributes': {'email': 'jackie.young_420@klaviyo-demo.com', 'phone_number': '(497)-005-8766', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jackie', 'last_name': 'Young', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Akron', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Alabama', 'zip': '81460', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XBYYPDPDVY8ER8ZVZAVK/'}}, {'type': 'profile', 'id': '01G111XC1SW1YFCY56YY8J1EPH', 'attributes': {'email': 'seth.west_876@klaviyo-demo.com', 'phone_number': '(767)-948-3329', 'external_id': None, 'anonymous_id': None, 'first_name': 'Seth', 'last_name': 'West', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Elizabeth', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Utah', 'zip': '11222', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XC1SW1YFCY56YY8J1EPH/'}}, {'type': 'profile', 'id': '01G111XC4N7ET5FM9JHPY58SRE', 'attributes': {'email': 'shelly.frazier_379@klaviyo-demo.com', 'phone_number': '(888)-705-0736', 'external_id': None, 'anonymous_id': None, 'first_name': 'Shelly', 'last_name': 'Frazier', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Mesquite', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Michigan', 'zip': '95178', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XC4N7ET5FM9JHPY58SRE/'}}, {'type': 'profile', 'id': '01G111XC7E8TEVMEPEQPYCNG5R', 'attributes': {'email': 'jack.robertson_823@klaviyo-demo.com', 'phone_number': '(429)-330-8723', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jack', 'last_name': 'Robertson', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Roseville', 'country': None, 'latitude': None, 'longitude': None, 'region': 'New Hampshire', 'zip': '21793', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XC7E8TEVMEPEQPYCNG5R/'}}, {'type': 'profile', 'id': '01G111XCAG76BRJ8SPK36D1PWM', 'attributes': {'email': 'alexander.adams_807@klaviyo-demo.com', 'phone_number': '(297)-743-4721', 'external_id': None, 'anonymous_id': None, 'first_name': 'Alexander', 'last_name': 'Adams', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'College Station', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Maine', 'zip': '31386', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XCAG76BRJ8SPK36D1PWM/'}}, {'type': 'profile', 'id': '01G111XCDBX5V6Q1B90EFM3ZVW', 'attributes': {'email': 'paul.meyer_623@klaviyo-demo.com', 'phone_number': '1-469-942-946', 'external_id': None, 'anonymous_id': None, 'first_name': 'Paul', 'last_name': 'Meyer', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:09+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Emilystad', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Maine', 'zip': '10359', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XCDBX5V6Q1B90EFM3ZVW/'}}, {'type': 'profile', 'id': '01G111XCG7QJK88F7WZSXJ93PE', 'attributes': {'email': 'beverly.lynch_140@klaviyo-demo.com', 'phone_number': '+19363663897', 'external_id': None, 'anonymous_id': None, 'first_name': 'Beverly', 'last_name': 'Lynch', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:10+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Ashburn', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Virginia', 'zip': '95246', 'timezone': 'America/New_York'}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XCG7QJK88F7WZSXJ93PE/'}}, {'type': 'profile', 'id': '01G111XCK0NWRS22Q1HCKY24AA', 'attributes': {'email': 'jackson.horton_852@klaviyo-demo.com', 'phone_number': '(996)-603-2873', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jackson', 'last_name': 'Horton', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:10+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Norman', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Nevada', 'zip': '88923', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XCK0NWRS22Q1HCKY24AA/'}}, {'type': 'profile', 'id': '01G111XCNKNPZW092FRM67FG4C', 'attributes': {'email': 'evelyn.henry_159@klaviyo-demo.com', 'phone_number': '(338)-045-8148', 'external_id': None, 'anonymous_id': None, 'first_name': 'Evelyn', 'last_name': 'Henry', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:10+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'York', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Delaware', 'zip': '22363', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XCNKNPZW092FRM67FG4C/'}}, {'type': 'profile', 'id': '01G111XCRBA38PGDEYDGBBRNZP', 'attributes': {'email': 'jayden.dunn_943@klaviyo-demo.com', 'phone_number': '(135)-973-9848', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jayden', 'last_name': 'Dunn', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:10+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Salinas', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Florida', 'zip': '75050', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XCRBA38PGDEYDGBBRNZP/'}}, {'type': 'profile', 'id': '01G111XCV2X8GJVA8W3XMCE39R', 'attributes': {'email': 'perry.gardner_523@klaviyo-demo.com', 'phone_number': '(302)-605-2829', 'external_id': None, 'anonymous_id': None, 'first_name': 'Perry', 'last_name': 'Gardner', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T13:59:10+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'St. Petersburg', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Illinois', 'zip': '79575', 'timezone': None}, 'properties': {}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G111XCV2X8GJVA8W3XMCE39R/'}}, {'type': 'profile', 'id': '01G11212JAGT5CRJZPZ0VJNCW2', 'attributes': {'email': 'christina.hamilton_714@klaviyo-demo.com', 'phone_number': '+17322813459', 'external_id': None, 'anonymous_id': None, 'first_name': 'Christina', 'last_name': 'Hamilton', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:10+00:00', 'updated': '2022-04-19T14:01:10+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '98214', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11212JAGT5CRJZPZ0VJNCW2/'}}, {'type': 'profile', 'id': '01G11212PJEHB20A4MWJZHPG8J', 'attributes': {'email': 'annette.castro_153@klaviyo-demo.com', 'phone_number': '+14627438500', 'external_id': None, 'anonymous_id': None, 'first_name': 'Annette', 'last_name': 'Castro', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '92444', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11212PJEHB20A4MWJZHPG8J/'}}, {'type': 'profile', 'id': '01G11212SM1AKKAEC4Y296M64V', 'attributes': {'email': 'jason.curtis_180@klaviyo-demo.com', 'phone_number': '+19103913500', 'external_id': None, 'anonymous_id': None, 'first_name': 'Jason', 'last_name': 'Curtis', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '99819', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11212SM1AKKAEC4Y296M64V/'}}, {'type': 'profile', 'id': '01G11212YGW2XHCVA021JAX5C1', 'attributes': {'email': 'wesley.harris_289@klaviyo-demo.com', 'phone_number': '+15781015118', 'external_id': None, 'anonymous_id': None, 'first_name': 'Wesley', 'last_name': 'Harris', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '34939', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11212YGW2XHCVA021JAX5C1/'}}, {'type': 'profile', 'id': '01G112131D779SWGS7KK14Y98Q', 'attributes': {'email': 'cathy.mendoza_352@klaviyo-demo.com', 'phone_number': '+15755455131', 'external_id': None, 'anonymous_id': None, 'first_name': 'Cathy', 'last_name': 'Mendoza', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '65853', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112131D779SWGS7KK14Y98Q/'}}, {'type': 'profile', 'id': '01G112136F128T4PT0XW3ZES6E', 'attributes': {'email': 'dora.bates_542@klaviyo-demo.com', 'phone_number': '+10084162299', 'external_id': None, 'anonymous_id': None, 'first_name': 'Dora', 'last_name': 'Bates', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '14259', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112136F128T4PT0XW3ZES6E/'}}, {'type': 'profile', 'id': '01G11213A97VRHG3GSYEJH419D', 'attributes': {'email': 'ben.medina_386@klaviyo-demo.com', 'phone_number': '+16481137343', 'external_id': None, 'anonymous_id': None, 'first_name': 'Ben', 'last_name': 'Medina', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '69305', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11213A97VRHG3GSYEJH419D/'}}, {'type': 'profile', 'id': '01G11213EAJXBW2SWZ8CC299W6', 'attributes': {'email': 'janet.berry_469@klaviyo-demo.com', 'phone_number': '+14081970361', 'external_id': None, 'anonymous_id': None, 'first_name': 'Janet', 'last_name': 'Berry', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '88551', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11213EAJXBW2SWZ8CC299W6/'}}, {'type': 'profile', 'id': '01G11213HGFXZDSK2TTAHQ6PXB', 'attributes': {'email': 'nathaniel.wheeler_110@klaviyo-demo.com', 'phone_number': '(635)-315-7555', 'external_id': None, 'anonymous_id': None, 'first_name': 'Nathaniel', 'last_name': 'Wheeler', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:11+00:00', 'updated': '2022-04-19T14:01:11+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Surrey', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Maine', 'zip': '36455', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11213HGFXZDSK2TTAHQ6PXB/'}}, {'type': 'profile', 'id': '01G11213MH2HGX8BAE3JF0JTF7', 'attributes': {'email': 'madison.wade_396@klaviyo-demo.com', 'phone_number': '+13766007485', 'external_id': None, 'anonymous_id': None, 'first_name': 'Madison', 'last_name': 'Wade', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:12+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '10809', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11213MH2HGX8BAE3JF0JTF7/'}}, {'type': 'profile', 'id': '01G11213QT4N5TSPS60E770BMQ', 'attributes': {'email': 'leonard.stewart_180@klaviyo-demo.com', 'phone_number': '+17652941861', 'external_id': None, 'anonymous_id': None, 'first_name': 'Leonard', 'last_name': 'Stewart', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:12+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '30464', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11213QT4N5TSPS60E770BMQ/'}}, {'type': 'profile', 'id': '01G11213WDYN0SF2YTFNN3YQA5', 'attributes': {'email': 'katie.harris_962@klaviyo-demo.com', 'phone_number': '+19803334387', 'external_id': None, 'anonymous_id': None, 'first_name': 'Katie', 'last_name': 'Harris', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:12+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '68918', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11213WDYN0SF2YTFNN3YQA5/'}}, {'type': 'profile', 'id': '01G112146JFQJA7XQP6B1XYA8B', 'attributes': {'email': 'brian.owens_502@klaviyo-demo.com', 'phone_number': '+18090798936', 'external_id': None, 'anonymous_id': None, 'first_name': 'Brian', 'last_name': 'Owens', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:12+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '87141', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112146JFQJA7XQP6B1XYA8B/'}}, {'type': 'profile', 'id': '01G112149M2CMV72ADEJPK3QYV', 'attributes': {'email': 'raymond.cervantes_607@klaviyo-demo.com', 'phone_number': '+16175555108', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Hansen Inc', 'title': 'Chief Executive Officer', 'image': None, 'created': '2022-04-19T14:01:12+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '2468 Tiffany Summit', 'address2': 'Suite 187', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '88523', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112149M2CMV72ADEJPK3QYV/'}}, {'type': 'profile', 'id': '01G11214ECQ64H2M3J8AGBQCC9', 'attributes': {'email': 'abigail.reyes_776@klaviyo-demo.com', 'phone_number': '+16175553616', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Wilson, Richard and Higgins', 'title': 'Market researcher', 'image': None, 'created': '2022-04-19T14:01:12+00:00', 'updated': '2022-04-19T14:01:12+00:00', 'last_event_date': None, 'location': {'address1': '0344 Green Common', 'address2': 'Apt. 635', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '54233', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11214ECQ64H2M3J8AGBQCC9/'}}, {'type': 'profile', 'id': '01G11214JD7AF38RXBDTK3ZYZ6', 'attributes': {'email': 'kim.keith_109@klaviyo-demo.com', 'phone_number': '+16175559114', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Perry and Sons', 'title': 'Therapist, horticultural', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '13209 Jon Spurs', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '82939', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11214JD7AF38RXBDTK3ZYZ6/'}}, {'type': 'profile', 'id': '01G11214Q4AD6RACEYCX3NV72P', 'attributes': {'email': 'ryan.gonzalez_061@klaviyo-demo.com', 'phone_number': '+16175559170', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Cabrera Group', 'title': 'Dispensing optician', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '30634 Marissa Dam', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '80881', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11214Q4AD6RACEYCX3NV72P/'}}, {'type': 'profile', 'id': '01G11214W0M1F4DKSFFWJQH58M', 'attributes': {'email': 'sierra.garza_588@klaviyo-demo.com', 'phone_number': '+16175559831', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Fisher, Sanders and Cook', 'title': 'Designer, jewellery', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '539 Sean Shore', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '36311', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11214W0M1F4DKSFFWJQH58M/'}}, {'type': 'profile', 'id': '01G11214Z9ZV51H8G5R0TYC3Y9', 'attributes': {'email': 'theodore.baker_511@klaviyo-demo.com', 'phone_number': '+16175554104', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Wilson-Anderson', 'title': 'Dietitian', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '5283 Baker Port', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '55407', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11214Z9ZV51H8G5R0TYC3Y9/'}}, {'type': 'profile', 'id': '01G112152EGQQN7GY2BEK8QH5R', 'attributes': {'email': 'laurie.wilson_980@klaviyo-demo.com', 'phone_number': '+16175554359', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Hampton Group', 'title': 'Scientific laboratory technician', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '68217 Rojas Fords', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '01219', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112152EGQQN7GY2BEK8QH5R/'}}, {'type': 'profile', 'id': '01G112157XA94S1A0PC3QHXWHX', 'attributes': {'email': 'charlotte.mullen_523@klaviyo-demo.com', 'phone_number': '+16175551529', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Cowan Inc', 'title': 'Chartered accountant', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '22843 Bryan Crest', 'address2': 'Suite 992', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '92819', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112157XA94S1A0PC3QHXWHX/'}}, {'type': 'profile', 'id': '01G11215C00RQRW869XR76QTCR', 'attributes': {'email': 'brooke.lopez_032@klaviyo-demo.com', 'phone_number': '+16175557617', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Levy-Brooks', 'title': 'Designer, jewellery', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:13+00:00', 'last_event_date': None, 'location': {'address1': '7702 Wilson Branch', 'address2': 'Apt. 004', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '77546', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11215C00RQRW869XR76QTCR/'}}, {'type': 'profile', 'id': '01G11215GRWKQD5V7W82H695WN', 'attributes': {'email': 'rick.lindsey_977@klaviyo-demo.com', 'phone_number': '+16175559918', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Thompson PLC', 'title': 'Herbalist', 'image': None, 'created': '2022-04-19T14:01:13+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '4197 Cory Lane', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '03384', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11215GRWKQD5V7W82H695WN/'}}, {'type': 'profile', 'id': '01G11215MMAWXJXE8NEQGSTVZH', 'attributes': {'email': 'kara.hughes_898@klaviyo-demo.com', 'phone_number': '+16175558210', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Hill, Williams and Chambers', 'title': 'Biochemist, clinical', 'image': None, 'created': '2022-04-19T14:01:14+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '807 Watson Junctions', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '41630', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11215MMAWXJXE8NEQGSTVZH/'}}, {'type': 'profile', 'id': '01G11215QMS7RF5NP353QN8WW5', 'attributes': {'email': 'rodney.wall_324@klaviyo-demo.com', 'phone_number': '+16175551645', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Mann, Calhoun and Ramos', 'title': 'Optometrist', 'image': None, 'created': '2022-04-19T14:01:14+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '218 Cox Track', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '07562', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11215QMS7RF5NP353QN8WW5/'}}, {'type': 'profile', 'id': '01G11215TTZXKJZCDV11JBVZ8S', 'attributes': {'email': 'james.hunt_619@klaviyo-demo.com', 'phone_number': '+16175556300', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Johnson-Lang', 'title': 'Production engineer', 'image': None, 'created': '2022-04-19T14:01:14+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '812 Robert Run', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '98188', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11215TTZXKJZCDV11JBVZ8S/'}}, {'type': 'profile', 'id': '01G11215XWVZVZJWMKH3B72RP2', 'attributes': {'email': 'lynn.stanley_435@klaviyo-demo.com', 'phone_number': '+16175553086', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Key-Wilson', 'title': 'Sound technician, broadcasting/film/video', 'image': None, 'created': '2022-04-19T14:01:14+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '409 Lauren Views', 'address2': 'Apt. 848', 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '03385', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11215XWVZVZJWMKH3B72RP2/'}}, {'type': 'profile', 'id': '01G112161WA3RN206KF6737745', 'attributes': {'email': 'cheryl.fleming_386@klaviyo-demo.com', 'phone_number': '+16175557922', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Floyd, York and Green', 'title': 'Agricultural consultant', 'image': None, 'created': '2022-04-19T14:01:14+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '8641 William Station', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '08704', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112161WA3RN206KF6737745/'}}, {'type': 'profile', 'id': '01G11216BBV5ZDT3ZB5NSWYHM7', 'attributes': {'email': 'diane.curtis_661@klaviyo-demo.com', 'phone_number': '+16175551125', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Mueller-Snyder', 'title': 'Civil engineer, consulting', 'image': None, 'created': '2022-04-19T14:01:14+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '631 Aguilar Club', 'address2': None, 'city': 'Tannertown', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'IN', 'zip': '73806', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11216BBV5ZDT3ZB5NSWYHM7/'}}, {'type': 'profile', 'id': '01G11216EC9095H23M51GGYNZG', 'attributes': {'email': 'teresa.perez_370@klaviyo-demo.com', 'phone_number': '+16175554011', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Matthews-Collins', 'title': 'Educational psychologist', 'image': None, 'created': '2022-04-19T14:01:14+00:00', 'updated': '2022-04-19T14:01:14+00:00', 'last_event_date': None, 'location': {'address1': '798 Walton Route', 'address2': 'Apt. 847', 'city': 'Michaelville', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'ID', 'zip': '27939', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11216EC9095H23M51GGYNZG/'}}, {'type': 'profile', 'id': '01G11216JZ5JPFXN20J3WRS2QN', 'attributes': {'email': 'william.fisher_546@klaviyo-demo.com', 'phone_number': '+16175552521', 'external_id': None, 'anonymous_id': None, 'first_name': None, 'last_name': None, 'organization': 'Peck, Howard and Parker', 'title': 'Colour technologist', 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': '5502 George Flats', 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '26354', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11216JZ5JPFXN20J3WRS2QN/'}}, {'type': 'profile', 'id': '01G11216VPG3RA36RGHA8Z1SJQ', 'attributes': {'email': 'joshua.kline_222@klaviyo-demo.com', 'phone_number': '1-515-493-858', 'external_id': None, 'anonymous_id': None, 'first_name': 'Joshua', 'last_name': 'Kline', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Andreaberg', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Washington', 'zip': '87452', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11216VPG3RA36RGHA8Z1SJQ/'}}, {'type': 'profile', 'id': '01G11216YT2MB5GQVFSK0405GY', 'attributes': {'email': 'timothy.young_682@klaviyo-demo.com', 'phone_number': '1-703-531-871', 'external_id': None, 'anonymous_id': None, 'first_name': 'Timothy', 'last_name': 'Young', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Lake Jakeborough', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Tennessee', 'zip': '79626', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11216YT2MB5GQVFSK0405GY/'}}, {'type': 'profile', 'id': '01G112171QX7HHAJVNEPF05QN7', 'attributes': {'email': 'karen.schwartz_374@klaviyo-demo.com', 'phone_number': '1-598-486-633', 'external_id': None, 'anonymous_id': None, 'first_name': 'Karen', 'last_name': 'Schwartz', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Mclaughlinmouth', 'country': None, 'latitude': None, 'longitude': None, 'region': 'New Hampshire', 'zip': '10831', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112171QX7HHAJVNEPF05QN7/'}}, {'type': 'profile', 'id': '01G112174N53ZJ7ER2YFJQ0MKY', 'attributes': {'email': 'meghan.chambers_243@klaviyo-demo.com', 'phone_number': '+11355882769', 'external_id': None, 'anonymous_id': None, 'first_name': 'Meghan', 'last_name': 'Chambers', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '60870', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112174N53ZJ7ER2YFJQ0MKY/'}}, {'type': 'profile', 'id': '01G112177KN5AQC05WVPSMW8AA', 'attributes': {'email': 'william.hensley_673@klaviyo-demo.com', 'phone_number': '1-917-987-492', 'external_id': None, 'anonymous_id': None, 'first_name': 'William', 'last_name': 'Hensley', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'West Nathaniel', 'country': None, 'latitude': None, 'longitude': None, 'region': 'West Virginia', 'zip': '37764', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112177KN5AQC05WVPSMW8AA/'}}, {'type': 'profile', 'id': '01G11217BEZ3EC0Z7D3ZSJ9JKA', 'attributes': {'email': 'leslie.bradley_983@klaviyo-demo.com', 'phone_number': '+14171889664', 'external_id': None, 'anonymous_id': None, 'first_name': 'Leslie', 'last_name': 'Bradley', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '84906', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11217BEZ3EC0Z7D3ZSJ9JKA/'}}, {'type': 'profile', 'id': '01G11217EBVTPV70TPE5DY7118', 'attributes': {'email': 'victor.clark_496@klaviyo-demo.com', 'phone_number': '1-466-454-635', 'external_id': None, 'anonymous_id': None, 'first_name': 'Victor', 'last_name': 'Clark', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:15+00:00', 'updated': '2022-04-19T14:01:15+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Morrowstad', 'country': None, 'latitude': None, 'longitude': None, 'region': 'Washington', 'zip': '54116', 'timezone': None}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11217EBVTPV70TPE5DY7118/'}}, {'type': 'profile', 'id': '01G11217KS9SNAF1MWQXZ1CP3H', 'attributes': {'email': 'rita.kelley_193@klaviyo-demo.com', 'phone_number': '+14112157696', 'external_id': None, 'anonymous_id': None, 'first_name': 'Rita', 'last_name': 'Kelley', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:16+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Ashburn', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Virginia', 'zip': '39932', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11217KS9SNAF1MWQXZ1CP3H/'}}, {'type': 'profile', 'id': '01G11217VB85G9CXGRP693HATT', 'attributes': {'email': 'travis.perry_148@klaviyo-demo.com', 'phone_number': '+16331537386', 'external_id': None, 'anonymous_id': None, 'first_name': 'Travis', 'last_name': 'Perry', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:16+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '57255', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G11217VB85G9CXGRP693HATT/'}}, {'type': 'profile', 'id': '01G112182M856GPM9DMTS8SR3N', 'attributes': {'email': 'corey.allen_878@klaviyo-demo.com', 'phone_number': '+11425617608', 'external_id': None, 'anonymous_id': None, 'first_name': 'Corey', 'last_name': 'Allen', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:16+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '34149', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112182M856GPM9DMTS8SR3N/'}}, {'type': 'profile', 'id': '01G112185MRANNC23YM9F8Z7FM', 'attributes': {'email': 'anthony.lewis_222@klaviyo-demo.com', 'phone_number': '+11696994940', 'external_id': None, 'anonymous_id': None, 'first_name': 'Anthony', 'last_name': 'Lewis', 'organization': None, 'title': None, 'image': None, 'created': '2022-04-19T14:01:16+00:00', 'updated': '2022-04-19T14:01:16+00:00', 'last_event_date': None, 'location': {'address1': None, 'address2': None, 'city': 'Columbus', 'country': 'United States', 'latitude': None, 'longitude': None, 'region': 'Ohio', 'zip': '06587', 'timezone': 'America/New_York'}, 'properties': {'Marketing': True}}, 'links': {'self': 'https://a.klaviyo.com/api/profiles/01G112185MRANNC23YM9F8Z7FM/'}}]
This task requires a few steps.
Developers should note that this task can be done through a few endpoints. In this example we will explore an implementation primarily using the \events
endpoint.
for metric in klaviyo.Metrics.get_metrics()['data']:
if metric['attributes']['name'] == 'Unsubscribed':
email_unsub_metric_id = metric['id']
elif metric['attributes']['name'] == 'Unsubscribed from SMS':
sms_unsub_metric_id = metric['id']
print(email_unsub_metric_id, sms_unsub_metric_id)
TzsTNe RWaivf
Note that the metric_ids returned for your account will be different than the ones shown above. Metric IDs are unique between accounts.
Note: The code below uses a filtering argument to tell Klaviyo's API what types of events we want pulled.
See here for a more in-depth description about how the filtering parameter works.
Each endpoint has different fields that can be used to filter outputs. Klaviyo's API documentation is the best place to see what fields can be passed in the filter query parameter.
# Note: does not include pagination (see step 3)
date_start_str = '2022-07-01T00:00:00'
date_end_str = '2022-08-16T00:00:00'
# Filter here is read as "A and B and C".
# Note that datetime strings are UTC and strings like metric_id need quotes surrounding
sms_unsub_filter = "greater-than(datetime,{}),less-than(datetime,{}),equals(metric_id,'{}')"\
.format(date_start_str, date_end_str, sms_unsub_metric_id)
email_unsub_filter = "greater-than(datetime,{}),less-than(datetime,{}),equals(metric_id,'{}')"\
.format(date_start_str, date_end_str, email_unsub_metric_id)
unsubscribed_sms_events = klaviyo.Events.get_events(filter=sms_unsub_filter)
unsubscribed_email_events = klaviyo.Events.get_events(filter=email_unsub_filter)
unsubscribed_sms_events
{'data': [{'type': 'event', 'id': '3sUU4MFTfZS', 'attributes': {'metric_id': 'RWaivf', 'profile_id': '01G7EZ8ZQ6WYC95XX7K4QKMPSF', 'timestamp': 1657286198, 'event_properties': {'$message': '01G7EZ90R53GGPRKJSXNYSABEP', 'extra': {'From City': 'Boston', 'From Country': 'US', 'From State': 'MA', 'Inbound Message ID': '02FYSJBBFPZKEMPAQ9NNRTCC14', 'Message ID': '01G7EZ90R53GGPRKJSXNYSABEP'}, 'From Number': '+15005550006', 'From Phone Region': 'US', 'Message Body': 'Stop', 'Method': 'text', 'To Number': '55896', 'To Phone Region': 'US', '$event_id': 'sample_data_gen:b144f140-1a4e-43af-b3e8-ddf3bf211ed0'}, 'datetime': '2022-07-08 13:16:38+00:00', 'uuid': '32bbff00-fec0-11ec-8001-11af83f24c98'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUU4MFTfZS/'}}], 'links': {'self': 'https://a.klaviyo.com/api/events/?filter=greater-than%28datetime%2C2022-07-01T00%3A00%3A00%29%2Cless-than%28datetime%2C2022-08-16T00%3A00%3A00%29%2Cequals%28metric_id%2C%27RWaivf%27%29', 'next': None, 'prev': None}}
unsubscribed_email_events
{'data': [{'type': 'event', 'id': '3sUSMjZwSMn', 'attributes': {'metric_id': 'TzsTNe', 'profile_id': '01G7EZ8ZJCM4V7CBQ4QSF4916C', 'timestamp': 1657286197, 'event_properties': {'$message': 'Rkp66a', 'Campaign Name': 'Internal Klaviyo - Test Campaign Name', 'Email Domain': 'klaviyo-demo.com', 'Subject': 'Internal Klaviyo - Subject Line', '$event_id': 'sample_data_gen:bb5f44dd-fae2-41a8-a1b8-4cccbea3b7fc'}, 'datetime': '2022-07-08 13:16:37+00:00', 'uuid': '32236880-fec0-11ec-8001-075bd83ca1b2'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUSMjZwSMn/'}}], 'links': {'self': 'https://a.klaviyo.com/api/events/?filter=greater-than%28datetime%2C2022-07-01T00%3A00%3A00%29%2Cless-than%28datetime%2C2022-08-16T00%3A00%3A00%29%2Cequals%28metric_id%2C%27TzsTNe%27%29', 'next': None, 'prev': None}}
With the given test account and parameters, there was only a single unsubscribe for each email and SMS. Looking at this output, developers certainly would not need to implement pagination.
For larger accounts though, these events may stretch into the thousands. Below is another example of how developers can implement pagination (similar to how it was implemented in Example 3.2).
In the interest of brevity, this only shows pagination for SMS unsubscribe events. Implementing the same for email should be nearly identical.
# Only shows pagination for SMS unsubscribes
date_start_str = '2022-07-01T00:00:00'
date_end_str = '2022-08-16T00:00:00'
# Filter here is read as "A and B and C".
# Note that datetime strings are UTC and strings like metric_id need quotes surrounding
sms_unsub_filter = "greater-than(datetime,{}),less-than(datetime,{}),equals(metric_id,'{}')"\
.format(date_start_str, date_end_str, sms_unsub_metric_id)
# pagination executed below
results_list = []
response = klaviyo.Events.get_events(filter=sms_unsub_filter)
results_list.extend(response['data'])
next_url = response['links']['next']
while next_url is not None:
next_cursor = get_page_cursor_from_url(next_url)
response = klaviyo.Events.get_events(filter=sms_unsub_filter, page_cursor=next_cursor)
results_list.extend(response['data'])
next_url = response['links']['next']
results_list
[{'type': 'event', 'id': '3sUU4MFTfZS', 'attributes': {'metric_id': 'RWaivf', 'profile_id': '01G7EZ8ZQ6WYC95XX7K4QKMPSF', 'timestamp': 1657286198, 'event_properties': {'$message': '01G7EZ90R53GGPRKJSXNYSABEP', 'extra': {'From City': 'Boston', 'From Country': 'US', 'From State': 'MA', 'Inbound Message ID': '02FYSJBBFPZKEMPAQ9NNRTCC14', 'Message ID': '01G7EZ90R53GGPRKJSXNYSABEP'}, 'From Number': '+15005550006', 'From Phone Region': 'US', 'Message Body': 'Stop', 'Method': 'text', 'To Number': '55896', 'To Phone Region': 'US', '$event_id': 'sample_data_gen:b144f140-1a4e-43af-b3e8-ddf3bf211ed0'}, 'datetime': '2022-07-08 13:16:38+00:00', 'uuid': '32bbff00-fec0-11ec-8001-11af83f24c98'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUU4MFTfZS/'}}]
Say we are interested in understanding customers brought in by a site-wide sale run during a Black Friday / Cyber Monday. We will use 2021 as an example.
This example is a bit more complicated than the prior ones and will involve chaining together the endpoints and concepts covered so far.
To make this easier to follow, we can break this task down into a series of smaller steps.
for metric in klaviyo.Metrics.get_metrics()['data']:
if metric['attributes']['name'] == 'Ordered Product':
print(metric)
# TODO: Update with your metric_id
ordered_product_metric_id = 'YOUR-METRIC-ID'
{'type': 'metric', 'id': 'UXjijJ', 'attributes': {'name': 'Ordered Product', 'created': '2022-04-19T13:34:12+00:00', 'updated': '2022-04-19T13:34:12+00:00', 'integration': {'object': 'integration', 'id': '0eMvjm', 'name': 'Shopify', 'category': 'eCommerce'}}, 'links': {'self': 'https://a.klaviyo.com/api/metrics/UXjijJ/'}} {'type': 'metric', 'id': 'XT5zvt', 'attributes': {'name': 'Ordered Product', 'created': '2022-07-08T13:16:39+00:00', 'updated': '2022-07-08T13:16:39+00:00', 'integration': {'object': 'integration', 'id': '7FtS4J', 'name': 'API', 'category': 'API'}}, 'links': {'self': 'https://a.klaviyo.com/api/metrics/XT5zvt/'}}
Developers should be aware that if they upload data into an account from multiple sources, then some metric names may appear more than once in Klaviyo (shown in printout above and screenshot below). This is because Klaviyo separates events based on their source.
So, if an account uploads events both with a custom integration and through a pre-built integration, then the account will appear to have metric duplicates. The test account used in this tutorial has events uploaded through Shopify and Klaviyo's APIs.
Events uploaded from different sources sometimes have different column names or data types. Klaviyo separates these metrics by default to help keep your data clean. Multiple integrations of the same type (e.g. multiple API integrations) will be grouped into the same bucket.
Klaviyo recommends developers keep metric names consistent regardless of the source (e.g. Ordered Product should not become Ordered Product (From Website)).
Klaviyo users of accounts with multiple integrations should be aware that their data is separated by source. Users who aren't aware of this nuance risk incomplete analytics and untriggered flows.
Note: for more detail on how to filter events, please see Klaviyo's filtering documentation.
bfcm_2021_start_utc = '2021-11-24T00:00:00' # thanksgiving day (thursday)
bfcm_2021_end_utc = '2021-11-29T00:00:00' # giving tuesday
# Filter here is read as "A and B and C".
# Note that datetime strings are UTC and strings like metric_id need quotes surrounding
total_filter = "greater-than(datetime,{}),less-than(datetime,{}),equals(metric_id,'{}')".format(date_start_str,
date_end_str,
ordered_product_metric_id)
# Note: does not include pagination
ordered_product_events = klaviyo.Events.get_events(filter=total_filter)
# display output
ordered_product_events
{'data': [{'type': 'event', 'id': '3xLmpbZdFTJ', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1660151407, 'event_properties': {'Categories': ['Fiction', 'Classics'], 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Ordered Product Value': 19.99, 'OrderId': 1235, 'ProductBrand': 'Harcourt Classics', 'ProductID': 1112, 'ProductName': 'A Tale of Two Cities', 'ProductURL': 'http://www.example.com/path/to/product', 'Quantity': 1, 'SKU': 'TALEOFTWO', '$event_id': 'ofurhjzbut', '$value': 0.0}, 'datetime': '2022-08-10 17:10:07+00:00', 'uuid': '48618180-18cf-11ed-8001-596c00eb5f8c'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3xLmpbZdFTJ/'}}, {'type': 'event', 'id': '3xKYGAANvxK', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1660147395, 'event_properties': {'Categories': ['Fiction', 'Classics'], 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Ordered Product Value': 19.99, 'OrderId': 1235, 'ProductBrand': 'Harcourt Classics', 'ProductID': 1112, 'ProductName': 'A Tale of Two Cities', 'ProductURL': 'http://www.example.com/path/to/product', 'Quantity': 1, 'SKU': 'TALEOFTWO', '$event_id': 'tdnfuvpnfv', '$value': 0.0}, 'datetime': '2022-08-10 16:03:15+00:00', 'uuid': 'f10ae380-18c5-11ed-8001-89098266a28b'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3xKYGAANvxK/'}}, {'type': 'event', 'id': '3xDgsSduhE8', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1660076676, 'event_properties': {'Categories': ['Fiction', 'Classics'], 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Ordered Product Value': 19.99, 'OrderId': 1235, 'ProductBrand': 'Harcourt Classics', 'ProductID': 1112, 'ProductName': 'A Tale of Two Cities', 'ProductURL': 'http://www.example.com/path/to/product', 'Quantity': 1, 'SKU': 'TALEOFTWO', '$event_id': 'rtqnrokytr', '$value': 0.0}, 'datetime': '2022-08-09 20:24:36+00:00', 'uuid': '493bda00-1821-11ed-8001-14d4df3aa2d7'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3xDgsSduhE8/'}}, {'type': 'event', 'id': '3xD9LpCLeyD', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1660075292, 'event_properties': {'Categories': ['Fiction', 'Classics'], 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Ordered Product Value': 19.99, 'OrderId': 1235, 'ProductBrand': 'Harcourt Classics', 'ProductID': 1112, 'ProductName': 'A Tale of Two Cities', 'ProductURL': 'http://www.example.com/path/to/product', 'Quantity': 1, 'SKU': 'TALEOFTWO', '$event_id': 'btsekdrvcf', '$value': 0.0}, 'datetime': '2022-08-09 20:01:32+00:00', 'uuid': '104e3600-181e-11ed-8001-96914e30f18d'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3xD9LpCLeyD/'}}, {'type': 'event', 'id': '3x36rYGS5rC', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1659716270, 'event_properties': {'custom attr1': 'val1', 'attr2': 50, '$event_id': 'xvzrixyghb', '$value': 0.0}, 'datetime': '2022-08-05 16:17:50+00:00', 'uuid': '26848b00-14da-11ed-8001-d9387f0164d7'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3x36rYGS5rC/'}}, {'type': 'event', 'id': '3x38kWyKapP', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1659716257, 'event_properties': {'custom attr1': 'val1', 'attr2': 50, '$event_id': 'lenpmfqgdp', '$value': 0.0}, 'datetime': '2022-08-05 16:17:37+00:00', 'uuid': '1ec4e680-14da-11ed-8001-cf9f59da4590'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3x38kWyKapP/'}}, {'type': 'event', 'id': '3x38YErjtj7', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1659716241, 'event_properties': {'custom attr1': 'val1', 'attr2': 50, '$event_id': 'vvvjaxqiwr', '$value': 0.0}, 'datetime': '2022-08-05 16:17:21+00:00', 'uuid': '153b7e80-14da-11ed-8001-b706285ee3b7'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3x38YErjtj7/'}}, {'type': 'event', 'id': '3x39ixzSkbq', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1659716208, 'event_properties': {'custom attr1': 'val1', 'attr2': 50, '$event_id': 'juyldvpdmu', '$value': 0.0}, 'datetime': '2022-08-05 16:16:48+00:00', 'uuid': '01901800-14da-11ed-8001-94dd95ac67d4'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3x39ixzSkbq/'}}, {'type': 'event', 'id': '3wUyGCbvVZi', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1659646809, 'event_properties': {'custom attr1': 'val1', 'attr2': 50, '$event_id': 'otaelbvvpc', '$value': 0.0}, 'datetime': '2022-08-04 21:00:09+00:00', 'uuid': '6c891280-1438-11ed-8001-50cf2921e9f1'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3wUyGCbvVZi/'}}, {'type': 'event', 'id': '3wKBZ2mEdYB', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1659537860, 'event_properties': {'$event_id': 'unique_id_placeholder', '$value': 0.0}, 'datetime': '2022-08-03 14:44:20+00:00', 'uuid': 'c1defa00-133a-11ed-8001-eee6571cef92'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3wKBZ2mEdYB/'}}, {'type': 'event', 'id': '3wJtnqDdM9w', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ9037GZ170GZ4NQEF5753', 'timestamp': 1659363322, 'event_properties': {'item_name': 'coool boooots', '$event_id': 'unique_id_for_event', '$value': 100.0}, 'datetime': '2022-08-01 14:15:22+00:00', 'uuid': '611db900-11a4-11ed-8001-72212f208d91'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3wJtnqDdM9w/'}}, {'type': 'event', 'id': '3sUVXDcTVDC', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ9037GZ170GZ4NQEF5753', 'timestamp': 1657286199, 'event_properties': {'OrderId': '1235', 'ProductID': '1112', 'SKU': 'TALEOFTWO', 'ProductName': 'A Tale of Two Cities', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Classics'], 'ProductBrand': 'Harcourt Classics', '$event_id': 'sample_data_gen:6507f903-cd66-426c-9672-09fd58b0e7ad', '$value': 19.99}, 'datetime': '2022-07-08 13:16:39+00:00', 'uuid': '33549580-fec0-11ec-8001-ad083fc890e7'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUVXDcTVDC/'}}, {'type': 'event', 'id': '3sUVDRqCBYV', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1657286199, 'event_properties': {'OrderId': '1235', 'ProductID': '1112', 'SKU': 'TALEOFTWO', 'ProductName': 'A Tale of Two Cities', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Classics'], 'ProductBrand': 'Harcourt Classics', '$event_id': 'sample_data_gen:99e8528d-a210-48da-adb4-95bb921cbe6f', '$value': 19.99}, 'datetime': '2022-07-08 13:16:39+00:00', 'uuid': '33549580-fec0-11ec-8001-0068284557f4'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUVDRqCBYV/'}}, {'type': 'event', 'id': '3sUVk3bR9gx', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ900W8H4TD8DH7HNH7MY3', 'timestamp': 1657286199, 'event_properties': {'OrderId': '1234', 'ProductID': '1111', 'SKU': 'WINNIEPOOH', 'ProductName': 'Winnie the Pooh', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Children'], 'ProductBrand': 'Kids Books', '$event_id': 'sample_data_gen:602c58ea-c2bf-4d0d-91b6-437423f2898a', '$value': 9.99}, 'datetime': '2022-07-08 13:16:39+00:00', 'uuid': '33549580-fec0-11ec-8001-e0700c8f8f97'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUVk3bR9gx/'}}, {'type': 'event', 'id': '3sUU4KfqEh6', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ9037GZ170GZ4NQEF5753', 'timestamp': 1657286199, 'event_properties': {'OrderId': '1234', 'ProductID': '1111', 'SKU': 'WINNIEPOOH', 'ProductName': 'Winnie the Pooh', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Children'], 'ProductBrand': 'Kids Books', '$event_id': 'sample_data_gen:fbc2409b-5165-4dbf-8425-c073b9ab214c', '$value': 9.99}, 'datetime': '2022-07-08 13:16:39+00:00', 'uuid': '33549580-fec0-11ec-8001-2abc7da04fe2'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUU4KfqEh6/'}}, {'type': 'event', 'id': '3sUU4JgPgEk', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ8ZYBH1QQWK9M04QZ57F0', 'timestamp': 1657286199, 'event_properties': {'OrderId': '1234', 'ProductID': '1111', 'SKU': 'WINNIEPOOH', 'ProductName': 'Winnie the Pooh', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Children'], 'ProductBrand': 'Kids Books', '$event_id': 'sample_data_gen:468694fe-bbfa-4b21-bc4c-2e6c8b012544', '$value': 9.99}, 'datetime': '2022-07-08 13:16:39+00:00', 'uuid': '33549580-fec0-11ec-8001-210575eb86fb'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUU4JgPgEk/'}}, {'type': 'event', 'id': '3sUU4Fm4tGt', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ8ZYBH1QQWK9M04QZ57F0', 'timestamp': 1657286199, 'event_properties': {'OrderId': '1235', 'ProductID': '1112', 'SKU': 'TALEOFTWO', 'ProductName': 'A Tale of Two Cities', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Classics'], 'ProductBrand': 'Harcourt Classics', '$event_id': 'sample_data_gen:1ddef87d-66b6-48b3-bdb7-8e0d80b2237c', '$value': 19.99}, 'datetime': '2022-07-08 13:16:39+00:00', 'uuid': '33549580-fec0-11ec-8001-6284870211a8'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUU4Fm4tGt/'}}, {'type': 'event', 'id': '3sUVk6AVd6p', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ8ZW2PAH2JE7BDWD6YR6E', 'timestamp': 1657286198, 'event_properties': {'OrderId': '1234', 'ProductID': '1111', 'SKU': 'WINNIEPOOH', 'ProductName': 'Winnie the Pooh', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Children'], 'ProductBrand': 'Kids Books', '$event_id': 'sample_data_gen:fe868bbe-cf5f-4491-9f4b-4e2a76ccbf6b', '$value': 9.99}, 'datetime': '2022-07-08 13:16:38+00:00', 'uuid': '32bbff00-fec0-11ec-8001-495c99f3f09f'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUVk6AVd6p/'}}, {'type': 'event', 'id': '3sUUGkMa4Lr', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ8ZSJZ8B633X2ZPZKZDKD', 'timestamp': 1657286198, 'event_properties': {'OrderId': '1235', 'ProductID': '1112', 'SKU': 'TALEOFTWO', 'ProductName': 'A Tale of Two Cities', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Classics'], 'ProductBrand': 'Harcourt Classics', '$event_id': 'sample_data_gen:3325fdf2-adbf-4dbb-85bf-2946a40ccab5', '$value': 19.99}, 'datetime': '2022-07-08 13:16:38+00:00', 'uuid': '32bbff00-fec0-11ec-8001-ac24e87eddcd'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUUGkMa4Lr/'}}, {'type': 'event', 'id': '3sUU4GjDiHd', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ8ZSJZ8B633X2ZPZKZDKD', 'timestamp': 1657286198, 'event_properties': {'OrderId': '1234', 'ProductID': '1111', 'SKU': 'WINNIEPOOH', 'ProductName': 'Winnie the Pooh', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Children'], 'ProductBrand': 'Kids Books', '$event_id': 'sample_data_gen:463c6e5c-d42a-43fe-a92f-24351440cdf9', '$value': 9.99}, 'datetime': '2022-07-08 13:16:38+00:00', 'uuid': '32bbff00-fec0-11ec-8001-4291e485459a'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUU4GjDiHd/'}}, {'type': 'event', 'id': '3sUU4CrgxX5', 'attributes': {'metric_id': 'XT5zvt', 'profile_id': '01G7EZ8ZW2PAH2JE7BDWD6YR6E', 'timestamp': 1657286198, 'event_properties': {'OrderId': '1235', 'ProductID': '1112', 'SKU': 'TALEOFTWO', 'ProductName': 'A Tale of Two Cities', 'Quantity': 1, 'ProductURL': 'http://www.example.com/path/to/product', 'ImageURL': 'http://www.example.com/path/to/product/image.png', 'Categories': ['Fiction', 'Classics'], 'ProductBrand': 'Harcourt Classics', '$event_id': 'sample_data_gen:a004336e-0ece-43db-badc-982fbf40b192', '$value': 19.99}, 'datetime': '2022-07-08 13:16:38+00:00', 'uuid': '32bbff00-fec0-11ec-8001-b0944804ffaa'}, 'links': {'self': 'https://a.klaviyo.com/api/events/3sUU4CrgxX5/'}}], 'links': {'self': 'https://a.klaviyo.com/api/events/?filter=greater-than%28datetime%2C2022-07-01T00%3A00%3A00%29%2Cless-than%28datetime%2C2022-08-16T00%3A00%3A00%29%2Cequals%28metric_id%2C%27XT5zvt%27%29', 'next': None, 'prev': None}}
Eagle-eyed developers may notice that the printouts for this example are using a different date range than Black Friday - Cyber Monday. This is simply because the test account used to generate the outputs did not have any events during that time period.
Unlike other code snippets shown in this guide, the block below uses a direct call to Klaviyo's V1 APIs rather than an indirect call through an SDK on Klaviyo's new APIs.
At the time of this guide's creation, the newest generation of Klaviyo's APIs is still in its early stages. At this point, the task below can only be done through the V1 APIs.
This functionality is a planned part of Klaviyo's new generation of APIs that is under development. As the new generation of APIs continue their development cycle, the code below will be updated to reflect how Klaviyo recommends developers use our APIs.
# convert start date from string to datetime
date_start_dt = datetime.strptime(date_start_str, '%Y-%m-%dT%H:%M:%S')
date_end_dt = datetime.strptime(date_end_str, '%Y-%m-%dT%H:%M:%S')
# output set of profile_ids
bfcm_2021_first_time_buyers = set()
# Note: This code snippet makes a direct call onto Klaviyo's V1 APIs
# Task: Iterate through BFCM 2021 orders to see if the customer's first order fits in the time range.
for order_event in ordered_product_events['data']:
# get relevant profile_ids
profile_id = order_event['attributes']['profile_id']
# grabs the profile's first Ordered Product (count=1, sorted ascending by date)
url = "https://a.klaviyo.com/api/v1/person/{}/metric/{}/timeline"\
"?count=1&sort=asc&api_key={}".format(profile_id, ordered_product_metric_id, private_key)
# header necessary for V1 APIs
headers = {"Accept": "application/json"}
response = requests.get(url, headers=headers)
# convert json to dict
data = json.loads(response.text)
# reformat first purchase date into a datetime object
first_event_datetime_str = data['data'][0]['datetime']
first_event_datetime = datetime.strptime(first_event_datetime_str[:-6], '%Y-%m-%d %H:%M:%S')
if (first_event_datetime > date_start_dt) and (first_event_datetime < date_end_dt):
# if customer first bought product in the given range, add to set
bfcm_2021_first_time_buyers.add(profile_id)
After that loop, we are left with the profile_ids
of accounts that meet the given criteria:
Let's next take a look at how we can use this information
# set of profile_ids
bfcm_2021_first_time_buyers
{'01G7EZ8ZSJZ8B633X2ZPZKZDKD', '01G7EZ8ZW2PAH2JE7BDWD6YR6E', '01G7EZ8ZYBH1QQWK9M04QZ57F0', '01G7EZ900W8H4TD8DH7HNH7MY3'}
Now that we have the profiles we wanted, we may want to save them for later use. We can do that by creating a list and uploading profiles to it.
Let's first take a look at how to create a list with Klaviyo's Python SDK.
Creating a list using Klaviyo's APIs requires passing a body describing the list to be created. This is fully detailed in Klaviyo's documentation.
# body describing new list
body = {
'data': {
'type': 'list',
'attributes': {
'name': '2021 BFCM First Time Buyers'
}
}
}
response = klaviyo.Lists.create_list(body)
# response object confirms metadata on newly created list
print(response)
# list_id is saved for future use in code blocks below
bfcm_2021_list_id = response['data']['id']
{'data': {'type': 'list', 'id': 'UKSuDW', 'attributes': {'name': '2021 BFCM First Time Buyers', 'created': '2022-10-19T22:04:29.688864+00:00', 'updated': '2022-10-19T22:04:29.688882+00:00'}, 'links': {'self': 'https://a.klaviyo.com/api/lists/UKSuDW/'}}}
Note: You may notice if you end up running the cell more than once that an account can have multiple lists with the same name. If your pipeline to create Lists is not configured well, you can end up creating many duplicate Lists.
In short, list_ids
are unique, but list names
are not.
After pulling the relevant profile_ids and creating a new list to house them, the next step is to upload the profiles to the list.
This can be done using Klaviyo's SDK as shown below:
# Iteratively adds profiles to the list. At this point, this process must be done one-by-one.
for profile_id in bfcm_2021_first_time_buyers:
payload = {
'data': [
{
'type': 'profile',
'id': profile_id
}
]
}
klaviyo.Lists.create_list_relationships(bfcm_2021_list_id, list_members_add_query=payload)
The newly created list is now visible - along with its uploaded profiles - in the Lists & Segments tab.
To summarize, we took a fairly complex request -- finding customers who made their first purchase during Black Friday / Cyber Monday -- and broke it into a number of smaller tasks:
This example chained together data and calls from the metrics
, profiles
, events
, and lists
endpoints and included the concepts such as filtering, sorting, and pagination.
Most developers use Klaviyo's APIs to launch simpler integrations and analyses -- especially when they are new to Klaviyo. This example is not meant to be a blueprint, but rather a spark for your imagination.
Developers able to follow along with this example should be well on their way to being able to dive into Klaviyo's data ecosystem.
Klaviyo lets businesses collect precise data on their customers and helps them use it to supercharge their growth. Developers -- especially those at larger businesses -- play a key role in turning this massive amount of information into actionable insights. Klaviyo's APIs are the best way for developers to take on this task.
To that end, Klaviyo's Developer Experience team is here to help. This new generation of APIs, paired with documentation and guides like this, aim to give developers more powerful tools and make their lives easier.
This guide started from the basics of how customer data in Klaviyo is structured to chaining together multiple endpoints to unlock net new functionality.
Developers with any more questions after reading this guide, should consider looking through the other guided code walkthroughs that are part of Klaviyo's documentation or reaching out to our talented Solution Architects: