Klaviyo-api

Latest version: v16.0.0

Safety actively analyzes 693883 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 5

11.0.0

Added
- Typed Responses (Breaking change)
- By default, all API methods will return a type representing the response payload instead of dictionary, as was the case in previous versions of this SDK. Using the typed response, you can access fields of a response using dot notation, like so:
python
from klaviyo_api import KlaviyoAPI

client = KlaviyoAPI(
api_key,
max_delay=0,
max_retries=0
)

profiles = client.Profiles.get_profiles()
profile_id = profiles.data[0].id
profile = client.Profiles.get_profile(profile_id)
profile_id = profile.data.id
profile_email = profile.data.attributes.email

print(type(profile).__name__) prints GetProfileResponseCompoundDocument

The class used in this example is found [here](src/openapi_client/models/get_profile_response_collection_compound_document.py).

This is a breaking change, as response objects will now require dot notation to access their fields versus the subscriptable access method used for dictionaries, i.e. `profile.data.id` vs `profile['data']['id']`. We have provided a [backwards compatibility strategy](backwards-compatibility) to smooth the transition from dictionary responses to typed responses.

Backwards Compatibility
To maintain backwards compatibility with previous versions of this SDK, we have added an `options` argument that allows you to continue using dictionaries as response values. There are two ways to use this `options` argument:
python
from klaviyo_api import KlaviyoAPI
from openapi_client.api_arg_options import USE_DICTIONARY_FOR_RESPONSE_DATA

client = KlaviyoAPI(
api_key,
max_delay=0,
max_retries=0
)


1: Passing options to an individual API method
profiles = client.Profiles.get_profiles(options= {
USE_DICTIONARY_FOR_RESPONSE_DATA: True
})
profile_id = profiles["data"][0]['id']
profile_email = profiles["data"][0]['attributes']['email']

2: Passing options to API Client
dictionary_client = KlaviyoAPI(
api_key,
max_delay=0,
max_retries=0,
options={USE_DICTIONARY_FOR_RESPONSE_DATA : True}
)
profiles_ = dictionary_client.Profiles.get_profiles()
profile_0_id = profiles_["data"][0]['id']

profile_0 = dictionary_client.Profiles.get_profile(id=profile_0_id)
profile_0_email = profile_0["data"]['attributes']['email']

The first way will only return a dictionary for that specific `get_profiles` call. The second makes it so that all API methods called using `dictionary_client` will return dictionaries as responses.

- Some API methods still return response data that is not fully typed. See the [Untyped Response Data for Specific APIs](README.mduntyped-response-data-for-specific-apis) in the README for more details.
- Filter Builder - A new class to help construct filter query parameters.
python
old_date = datetime.datetime(2023, 8, 15, 12, 30, 0, 0, tzinfo=datetime.timezone.utc)
f = FilterBuilder()
f.any("email", ["sarah.masonklaviyo-demo.com", "smklaviyo-demo.com"])
f.greater_than("created", old_date)

f.build() returns 'any(email,["sarah.masonklaviyo-demo.com","smklaviyo-demo.com"]),greater-than(created,2023-08-15T12:30:00+00:00)'
profile_response = client.Profiles.get_profiles(filter=f.build())

You can also chain FilterBuilder methods
f = FilterBuilder()
filters = f.any("email", ["sarah.masonklaviyo-demo.com", "smklaviyo-demo.com"]).greater_than("created", date).build()
assert filters == "any(email,['sarah.masonklaviyo-demo.com','smklaviyo-demo.com']),greater-than(created,2023-08-15T12:30:00+00:00)"

10.0.0

Added

- Forms API
- New `klaviyo.Forms` class with methods to get forms, form versions and relationships
- Webhooks API
- new `klaviyo.Webooks` class containing CRUD operations for webhooks

Changed
- `klaviyo.Profiles.subscribe()`
- added `historical_import` flag for importing historically consented profiles can now be optionally supplied in the payload for the Subscribe Profiles endpoint.
- When using this flag, a consented_at date must be provided and must be in the past.

9.0.0

Added
- Segments Api
- New create segment endpoint `SegmentsApi.createSegment()`.
- New delete segment endpoint `SegementsApi.deleteSegment()`.
- Updated exisiting segments endpoints to include the segment definition
- For more information, see our [Segments API overview](https://developers.klaviyo.com/en/reference/segments_api_overview).

- Flows Api
- New delete flows endpoint `FlowsApi.deleteFlow()`

8.0.1

Added

- Fixes issue where `filter` query params for any API call were being duplicated on request send. See issue: https://github.com/klaviyo/klaviyo-api-python/issues/51

8.0.0

Added

- Bulk Create Events API with
- We have added support for creating events in bulk via the EventsApi.bulkCreateEvents method
- Create multiple events for new and existing profiles and/or update profile properties in a single API call. For more information, see our [Events API overview](https://developers.klaviyo.com/en/reference/events_api_overview).

Changed

- Accounts API
- `Accounts.get_account` and `Accounts.get_accounts` have been updated to return the account's locale, e.g. `"en-US"`.

- **Breaking**
- Subscribe API Synchronous Validation Improved
- To provide better feedback for handling SMS subscriptions, we’ve added improved validation behavior to ProfilesApi.subscribeProfiles method. In prior revisions, such requests may appear as 202s but will fail to update SMS consent. To handle this issue, 400 validation errors are returned for the following cases
1. If a profile is subscribed to SMS marketing and [age-gating is enabled](https://help.klaviyo.com/hc/en-us/articles/4408311712667) but age_gated_date_of_birth is not provided, or the DOB does not meet the region's requirements.
2. If the account does not have a sending number in the phone number’s region.
3. If the phone number is in a region not supported by Klaviyo.
4. If consented_at is set and the list or global setting is double opt-in.
- Pydantic V2
- This SDK now uses Pydantic V2. This may cause some compatibility issues if your source code depends on Pydantic V1.
- Renamed Fields in SDK
- As of the 2024-05-15 release, some models fields are named differently than they appear in API documentation. These fields are
- `datetime`: renamed to `datetime_`
- `date`: renamed to `date_`

This is to manage compatibility with Pydantic v2. An example of this can be seen in [StaticScheduleOptions](src/openapi_client/models/static_schedule_options.py).

python
class StaticScheduleOptions(BaseModel):
"""
StaticScheduleOptions
""" noqa: E501
datetime_: datetime = Field(description="The time to send at", alias="datetime")

schedule_options = StaticScheduleOptions(datetime_=datetime.datetime.strptime("2024-05-19T00:00:00+00:00", "%Y-%m-%dT%H:%M:%S%z")
print(schedule_options.datetime_)

7.0.0

Added:

- New `ReportingApi` allows you to request campaign and flow performance data that you can view in the Klaviyo UI.

- `campaign_values_query`
- Request campaign analytics data, for example, a campaign performance report on the open rate over the past 30 days.

- `flow_values_query`
- Request flow analytics data, for example, a flow performance report on the revenue per recipient value over the past 3 months.

- `flow_series_query`
- Fetch flow series data for a specific interval and timeframe, for example, a flow performance report on weekly click rates over the past 12 months.


- New `ProfilesApi` endpoint allows you to create or update a profile with a set of profile attributes.

- `create_or_update_profile`
- This endpoint operates synchronously and offers an upsert pattern similar to the [v1/v2 Identify API](https://developers.klaviyo.com/en/docs/apis_comparison_chart).

Changed:

- Removed the $attribution field from event_properties in get_event and get_events (breaking change).

- To include this data in your request, add include=attributions to your request.

Page 2 of 5

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.