Klaviyo Python SDK
- SDK version: 15.0.0
- API revision: 2024-10-15
Table of Contents
Helpful Resources
Design & Approach
This SDK is a thin wrapper around our API. See our API Reference for full documentation on behavior.
This SDK exactly mirrors the organization and naming convention of the above language-agnostic resources, with a few namespace changes to make it Pythonic (details in Appendix).
Organization
This SDK is organized into the following resources:
-
Accounts
-
Campaigns
-
Catalogs
-
Coupons
-
Data_Privacy
-
Events
-
Flows
-
Forms
-
Images
-
Lists
-
Metrics
-
Profiles
-
Reporting
-
Reviews
-
Segments
-
Tags
-
Templates
-
Tracking_Settings
-
Webhooks
Installation
You can install this library using our pip package here.
Depending on your system configuration, you will need to run one of the following shell commands:
pip install klaviyo-api
OR
pip3 install klaviyo-api
Usage Example
To instantiate the client
NOTE:
- The SDK retries on resolvable errors, namely: rate limits (common) and server errors (rare).
- The keyword arguments define some advanced settings; the example is populated with the default values.
max_delay
denotes total delay (in seconds) across all attempts.
from klaviyo_api import KlaviyoAPI
klaviyo = KlaviyoAPI("YOUR_API_KEY_HERE", max_delay=60, max_retries=3, test_host=None)
Example request
klaviyo.Metrics.get_metrics()
Use Case Examples
How to use filtering, sorting, and spare fieldset JSON API features
Use Case: Get events associated with a specific metric, then return just the event properties sorted by oldest to newest datetime.
klaviyo.Events.get_events(
fields_event=['event_properties'],
filter="equals(metric_id,\"aBc123\")",
sort='-datetime'
)
How to filter based on datetime
Use Case: Get profiles that have been updated between two datetimes.
klaviyo.Profiles.get_profiles(
filter='less-than(updated,2023-04-26T00:00:00Z),greater-than(updated,2023-04-19T00:00:00Z)'
)
How to use pagination and the page[size] param
Use Case: Use cursor-based pagination to get the next 20 profile records.
klaviyo.Profiles.get_profiles(
page_cursor="https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6OjAxRjNaWk5ITlRYMUtFVEhQMzJTUzRBN0ZY",
page_size=20
)
NOTE: This page cursor value is exactly what is returned in the self
/next
/prev
response values
How to add additional information to your API response via additional-fields and the includes
parameter
Use Case: Get a specific profile, return an additional predictive analytics field, and also return the list objects associated with the profile.
klaviyo.Profiles.get_profile(
'01GDDKASAP8TKDDA2GRZDSVP4H',
additional_fields_profile=['predictive_analytics'],
include=['lists']
)
How to use our relationship endpoints to see related resources
Use Case: Get all list memberships for a profile with the given profile_id
.
klaviyo.Profiles.get_profile_relationships_lists('01GDDKASAP8TKDDA2GRZDSVP4H')
How to see what Klaviyo objects are associated with a specific tag
Use Case: Get all campaigns associated with the given tag_id
.
klaviyo.Tags.get_tag_relationships_campaigns('9c8db7a0-5ab5-4e3c-9a37-a3224fd14382')
Uploading Image From File
When using Images.upload_image_from_file(file, name=name)
, `file`` can be either a file path string OR a bytearray.
NOTE: when file is a bytearray, you will need to use the optional name
parameter to specify the file name, else name will default to unnamed_image_from_python_sdk
as a file path
filepath = '/path/to/image.png'
klaviyo.Images.upload_image_from_file(file, name=name)
as a bytearray
filepath = '/path/to/image.png'
with open(filepath, 'rb') as f:
file = f.read()
klaviyo.Images.upload_image_from_file(file, name=name)
Error Handling
This SDK throws an ApiException
error when the server returns a non-2XX
response.
An ApiException
consists of the following attributes:
Important Notes
- The main difference between this SDK and the language-agnostic API Docs that the below endpoints link to is that this SDK automatically adds the
revision
header corresponding to the SDK version. - Organization: Resource groups and operation_ids are listed below in alphabetical order, first by Resource name, then by OpenAPI Summary. Operation summaries are those listed in the right side bar of the API Reference.
- For example values / data types, as well as whether parameters are required/optional, please reference the corresponding API Reference link.
- Some keyword args may potentially be required for the API call to succeed, the linked API docs are the source of truth regarding which keyword params are required.
- JSON payloads should be passed in as native python dictionaries.
- You can override the client private key by passing in an optional
_request_auth
keyword arg to any API call that takes a private key. As a reminder: do NOT do this client-side/onsite.
Comprehensive List of Operations & Parameters
Accounts
klaviyo.Accounts.get_account(id, fields_account=fields_account)
klaviyo.Accounts.get_accounts(fields_account=fields_account)
Campaigns
klaviyo.Campaigns.assign_template_to_campaign_message(body)
Method alias:
klaviyo.Campaigns.create_campaign_message_assign_template(body)
klaviyo.Campaigns.cancel_campaign_send(id, body)
Method alias:
klaviyo.Campaigns.update_campaign_send_job(id, body)
klaviyo.Campaigns.create_campaign(body)
klaviyo.Campaigns.create_campaign_clone(body)
Method alias:
klaviyo.Campaigns.clone_campaign(body)
klaviyo.Campaigns.delete_campaign(id)
klaviyo.Campaigns.get_campaign(id, fields_campaign_message=fields_campaign_message, fields_campaign=fields_campaign, fields_tag=fields_tag, include=include)
klaviyo.Campaigns.get_campaign_for_campaign_message(id, fields_campaign=fields_campaign)
Method alias:
klaviyo.Campaigns.get_campaign_message_campaign(id, fields_campaign=fields_campaign)
klaviyo.Campaigns.get_campaign_id_for_campaign_message(id)
Method alias:
klaviyo.Campaigns.get_campaign_message_relationships_campaign(id)
klaviyo.Campaigns.get_campaign_message(id, fields_campaign_message=fields_campaign_message, fields_campaign=fields_campaign, fields_template=fields_template, include=include)
klaviyo.Campaigns.get_campaign_recipient_estimation(id, fields_campaign_recipient_estimation=fields_campaign_recipient_estimation)
klaviyo.Campaigns.get_campaign_recipient_estimation_job(id, fields_campaign_recipient_estimation_job=fields_campaign_recipient_estimation_job)
klaviyo.Campaigns.get_campaign_send_job(id, fields_campaign_send_job=fields_campaign_send_job)
klaviyo.Campaigns.get_campaign_tags(id, fields_tag=fields_tag)
klaviyo.Campaigns.get_campaigns(filter, fields_campaign_message=fields_campaign_message, fields_campaign=fields_campaign, fields_tag=fields_tag, include=include, page_cursor=page_cursor, sort=sort)
klaviyo.Campaigns.get_message_ids_for_campaign(id)
Method alias:
klaviyo.Campaigns.get_campaign_relationships_campaign_messages(id)
klaviyo.Campaigns.get_messages_for_campaign(id, fields_campaign_message=fields_campaign_message, fields_campaign=fields_campaign, fields_template=fields_template, include=include)
Method alias:
klaviyo.Campaigns.get_campaign_campaign_messages(id, fields_campaign_message=fields_campaign_message, fields_campaign=fields_campaign, fields_template=fields_template, include=include)
klaviyo.Campaigns.get_tag_ids_for_campaign(id)
Method alias:
klaviyo.Campaigns.get_campaign_relationships_tags(id)
klaviyo.Campaigns.get_template_for_campaign_message(id, fields_template=fields_template)
Method alias:
klaviyo.Campaigns.get_campaign_message_template(id, fields_template=fields_template)
klaviyo.Campaigns.get_template_id_for_campaign_message(id)
Method alias:
klaviyo.Campaigns.get_campaign_message_relationships_template(id)
klaviyo.Campaigns.refresh_campaign_recipient_estimation(body)
Method alias:
klaviyo.Campaigns.create_campaign_recipient_estimation_job(body)
klaviyo.Campaigns.send_campaign(body)
Method alias:
klaviyo.Campaigns.create_campaign_send_job(body)
klaviyo.Campaigns.update_campaign(id, body)
klaviyo.Campaigns.update_campaign_message(id, body)
Catalogs
klaviyo.Catalogs.add_category_to_catalog_item(id, body)
Method alias:
klaviyo.Catalogs.create_catalog_item_relationships_categories(id, body)
Method alias:
klaviyo.Catalogs.create_catalog_item_relationships_category(id, body)
klaviyo.Catalogs.add_items_to_catalog_category(id, body)
Method alias:
klaviyo.Catalogs.create_catalog_category_relationships_items(id, body)
Method alias:
klaviyo.Catalogs.create_catalog_category_relationships_item(id, body)
klaviyo.Catalogs.bulk_create_catalog_categories(body)
Method alias:
klaviyo.Catalogs.spawn_create_categories_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_category_bulk_create_job(body)
klaviyo.Catalogs.bulk_create_catalog_items(body)
Method alias:
klaviyo.Catalogs.spawn_create_items_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_item_bulk_create_job(body)
klaviyo.Catalogs.bulk_create_catalog_variants(body)
Method alias:
klaviyo.Catalogs.spawn_create_variants_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_variant_bulk_create_job(body)
klaviyo.Catalogs.bulk_delete_catalog_categories(body)
Method alias:
klaviyo.Catalogs.spawn_delete_categories_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_category_bulk_delete_job(body)
klaviyo.Catalogs.bulk_delete_catalog_items(body)
Method alias:
klaviyo.Catalogs.spawn_delete_items_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_item_bulk_delete_job(body)
klaviyo.Catalogs.bulk_delete_catalog_variants(body)
Method alias:
klaviyo.Catalogs.spawn_delete_variants_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_variant_bulk_delete_job(body)
klaviyo.Catalogs.bulk_update_catalog_categories(body)
Method alias:
klaviyo.Catalogs.spawn_update_categories_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_category_bulk_update_job(body)
klaviyo.Catalogs.bulk_update_catalog_items(body)
Method alias:
klaviyo.Catalogs.spawn_update_items_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_item_bulk_update_job(body)
klaviyo.Catalogs.bulk_update_catalog_variants(body)
Method alias:
klaviyo.Catalogs.spawn_update_variants_job(body)
Method alias:
klaviyo.Catalogs.create_catalog_variant_bulk_update_job(body)
klaviyo.Catalogs.create_back_in_stock_subscription(body)
klaviyo.Catalogs.create_catalog_category(body)
klaviyo.Catalogs.create_catalog_item(body)
klaviyo.Catalogs.create_catalog_variant(body)
klaviyo.Catalogs.delete_catalog_category(id)
klaviyo.Catalogs.delete_catalog_item(id)
klaviyo.Catalogs.delete_catalog_variant(id)
klaviyo.Catalogs.get_bulk_create_catalog_items_job(job_id, fields_catalog_item_bulk_create_job=fields_catalog_item_bulk_create_job, fields_catalog_item=fields_catalog_item, include=include)
Method alias:
klaviyo.Catalogs.get_create_items_job(job_id, fields_catalog_item_bulk_create_job=fields_catalog_item_bulk_create_job, fields_catalog_item=fields_catalog_item, include=include)
Method alias:
klaviyo.Catalogs.get_catalog_item_bulk_create_job(job_id, fields_catalog_item_bulk_create_job=fields_catalog_item_bulk_create_job, fields_catalog_item=fields_catalog_item, include=include)
klaviyo.Catalogs.get_bulk_create_catalog_items_jobs(fields_catalog_item_bulk_create_job=fields_catalog_item_bulk_create_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_create_items_jobs(fields_catalog_item_bulk_create_job=fields_catalog_item_bulk_create_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_item_bulk_create_jobs(fields_catalog_item_bulk_create_job=fields_catalog_item_bulk_create_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_bulk_delete_catalog_items_job(job_id, fields_catalog_item_bulk_delete_job=fields_catalog_item_bulk_delete_job)
Method alias:
klaviyo.Catalogs.get_delete_items_job(job_id, fields_catalog_item_bulk_delete_job=fields_catalog_item_bulk_delete_job)
Method alias:
klaviyo.Catalogs.get_catalog_item_bulk_delete_job(job_id, fields_catalog_item_bulk_delete_job=fields_catalog_item_bulk_delete_job)
klaviyo.Catalogs.get_bulk_delete_catalog_items_jobs(fields_catalog_item_bulk_delete_job=fields_catalog_item_bulk_delete_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_delete_items_jobs(fields_catalog_item_bulk_delete_job=fields_catalog_item_bulk_delete_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_item_bulk_delete_jobs(fields_catalog_item_bulk_delete_job=fields_catalog_item_bulk_delete_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_bulk_update_catalog_items_job(job_id, fields_catalog_item_bulk_update_job=fields_catalog_item_bulk_update_job, fields_catalog_item=fields_catalog_item, include=include)
Method alias:
klaviyo.Catalogs.get_update_items_job(job_id, fields_catalog_item_bulk_update_job=fields_catalog_item_bulk_update_job, fields_catalog_item=fields_catalog_item, include=include)
Method alias:
klaviyo.Catalogs.get_catalog_item_bulk_update_job(job_id, fields_catalog_item_bulk_update_job=fields_catalog_item_bulk_update_job, fields_catalog_item=fields_catalog_item, include=include)
klaviyo.Catalogs.get_bulk_update_catalog_items_jobs(fields_catalog_item_bulk_update_job=fields_catalog_item_bulk_update_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_update_items_jobs(fields_catalog_item_bulk_update_job=fields_catalog_item_bulk_update_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_item_bulk_update_jobs(fields_catalog_item_bulk_update_job=fields_catalog_item_bulk_update_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_catalog_categories(fields_catalog_category=fields_catalog_category, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Catalogs.get_catalog_category(id, fields_catalog_category=fields_catalog_category)
klaviyo.Catalogs.get_catalog_item(id, fields_catalog_item=fields_catalog_item, fields_catalog_variant=fields_catalog_variant, include=include)
klaviyo.Catalogs.get_catalog_items(fields_catalog_item=fields_catalog_item, fields_catalog_variant=fields_catalog_variant, filter=filter, include=include, page_cursor=page_cursor, sort=sort)
klaviyo.Catalogs.get_catalog_variant(id, fields_catalog_variant=fields_catalog_variant)
klaviyo.Catalogs.get_catalog_variants(fields_catalog_variant=fields_catalog_variant, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Catalogs.get_categories_for_catalog_item(id, fields_catalog_category=fields_catalog_category, filter=filter, page_cursor=page_cursor, sort=sort)
Method alias:
klaviyo.Catalogs.get_catalog_item_categories(id, fields_catalog_category=fields_catalog_category, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Catalogs.get_category_ids_for_catalog_item(id, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_item_relationships_categories(id, page_cursor=page_cursor)
klaviyo.Catalogs.get_create_categories_job(job_id, fields_catalog_category_bulk_create_job=fields_catalog_category_bulk_create_job, fields_catalog_category=fields_catalog_category, include=include)
Method alias:
klaviyo.Catalogs.get_catalog_category_bulk_create_job(job_id, fields_catalog_category_bulk_create_job=fields_catalog_category_bulk_create_job, fields_catalog_category=fields_catalog_category, include=include)
klaviyo.Catalogs.get_create_categories_jobs(fields_catalog_category_bulk_create_job=fields_catalog_category_bulk_create_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_category_bulk_create_jobs(fields_catalog_category_bulk_create_job=fields_catalog_category_bulk_create_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_create_variants_job(job_id, fields_catalog_variant_bulk_create_job=fields_catalog_variant_bulk_create_job, fields_catalog_variant=fields_catalog_variant, include=include)
Method alias:
klaviyo.Catalogs.get_catalog_variant_bulk_create_job(job_id, fields_catalog_variant_bulk_create_job=fields_catalog_variant_bulk_create_job, fields_catalog_variant=fields_catalog_variant, include=include)
klaviyo.Catalogs.get_create_variants_jobs(fields_catalog_variant_bulk_create_job=fields_catalog_variant_bulk_create_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_variant_bulk_create_jobs(fields_catalog_variant_bulk_create_job=fields_catalog_variant_bulk_create_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_delete_categories_job(job_id, fields_catalog_category_bulk_delete_job=fields_catalog_category_bulk_delete_job)
Method alias:
klaviyo.Catalogs.get_catalog_category_bulk_delete_job(job_id, fields_catalog_category_bulk_delete_job=fields_catalog_category_bulk_delete_job)
klaviyo.Catalogs.get_delete_categories_jobs(fields_catalog_category_bulk_delete_job=fields_catalog_category_bulk_delete_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_category_bulk_delete_jobs(fields_catalog_category_bulk_delete_job=fields_catalog_category_bulk_delete_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_delete_variants_job(job_id, fields_catalog_variant_bulk_delete_job=fields_catalog_variant_bulk_delete_job)
Method alias:
klaviyo.Catalogs.get_catalog_variant_bulk_delete_job(job_id, fields_catalog_variant_bulk_delete_job=fields_catalog_variant_bulk_delete_job)
klaviyo.Catalogs.get_delete_variants_jobs(fields_catalog_variant_bulk_delete_job=fields_catalog_variant_bulk_delete_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_variant_bulk_delete_jobs(fields_catalog_variant_bulk_delete_job=fields_catalog_variant_bulk_delete_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_item_ids_for_catalog_category(id, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_category_relationships_items(id, page_cursor=page_cursor)
klaviyo.Catalogs.get_items_for_catalog_category(id, fields_catalog_item=fields_catalog_item, fields_catalog_variant=fields_catalog_variant, filter=filter, include=include, page_cursor=page_cursor, sort=sort)
Method alias:
klaviyo.Catalogs.get_catalog_category_items(id, fields_catalog_item=fields_catalog_item, fields_catalog_variant=fields_catalog_variant, filter=filter, include=include, page_cursor=page_cursor, sort=sort)
klaviyo.Catalogs.get_update_categories_job(job_id, fields_catalog_category_bulk_update_job=fields_catalog_category_bulk_update_job, fields_catalog_category=fields_catalog_category, include=include)
Method alias:
klaviyo.Catalogs.get_catalog_category_bulk_update_job(job_id, fields_catalog_category_bulk_update_job=fields_catalog_category_bulk_update_job, fields_catalog_category=fields_catalog_category, include=include)
klaviyo.Catalogs.get_update_categories_jobs(fields_catalog_category_bulk_update_job=fields_catalog_category_bulk_update_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_category_bulk_update_jobs(fields_catalog_category_bulk_update_job=fields_catalog_category_bulk_update_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_update_variants_job(job_id, fields_catalog_variant_bulk_update_job=fields_catalog_variant_bulk_update_job, fields_catalog_variant=fields_catalog_variant, include=include)
Method alias:
klaviyo.Catalogs.get_catalog_variant_bulk_update_job(job_id, fields_catalog_variant_bulk_update_job=fields_catalog_variant_bulk_update_job, fields_catalog_variant=fields_catalog_variant, include=include)
klaviyo.Catalogs.get_update_variants_jobs(fields_catalog_variant_bulk_update_job=fields_catalog_variant_bulk_update_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Catalogs.get_catalog_variant_bulk_update_jobs(fields_catalog_variant_bulk_update_job=fields_catalog_variant_bulk_update_job, filter=filter, page_cursor=page_cursor)
klaviyo.Catalogs.get_variants_for_catalog_item(id, fields_catalog_variant=fields_catalog_variant, filter=filter, page_cursor=page_cursor, sort=sort)
Method alias:
klaviyo.Catalogs.get_catalog_item_variants(id, fields_catalog_variant=fields_catalog_variant, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Catalogs.remove_categories_from_catalog_item(id, body)
Method alias:
klaviyo.Catalogs.delete_catalog_item_relationships_categories(id, body)
klaviyo.Catalogs.remove_items_from_catalog_category(id, body)
Method alias:
klaviyo.Catalogs.delete_catalog_category_relationships_items(id, body)
klaviyo.Catalogs.update_catalog_category(id, body)
klaviyo.Catalogs.update_catalog_item(id, body)
klaviyo.Catalogs.update_catalog_variant(id, body)
klaviyo.Catalogs.update_categories_for_catalog_item(id, body)
Method alias:
klaviyo.Catalogs.update_catalog_item_relationships_categories(id, body)
klaviyo.Catalogs.update_items_for_catalog_category(id, body)
Method alias:
klaviyo.Catalogs.update_catalog_category_relationships_items(id, body)
Coupons
klaviyo.Coupons.bulk_create_coupon_codes(body)
Method alias:
klaviyo.Coupons.spawn_coupon_code_bulk_create_job(body)
Method alias:
klaviyo.Coupons.create_coupon_code_bulk_create_job(body)
klaviyo.Coupons.create_coupon(body)
klaviyo.Coupons.create_coupon_code(body)
klaviyo.Coupons.delete_coupon(id)
klaviyo.Coupons.delete_coupon_code(id)
klaviyo.Coupons.get_bulk_create_coupon_code_jobs(fields_coupon_code_bulk_create_job=fields_coupon_code_bulk_create_job, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Coupons.get_coupon_code_bulk_create_jobs(fields_coupon_code_bulk_create_job=fields_coupon_code_bulk_create_job, filter=filter, page_cursor=page_cursor)
klaviyo.Coupons.get_bulk_create_coupon_codes_job(job_id, fields_coupon_code_bulk_create_job=fields_coupon_code_bulk_create_job, fields_coupon_code=fields_coupon_code, include=include)
Method alias:
klaviyo.Coupons.get_coupon_code_bulk_create_job(job_id, fields_coupon_code_bulk_create_job=fields_coupon_code_bulk_create_job, fields_coupon_code=fields_coupon_code, include=include)
klaviyo.Coupons.get_code_ids_for_coupon(id, page_cursor=page_cursor)
Method alias:
klaviyo.Coupons.get_coupon_code_relationships_coupon(id, page_cursor=page_cursor)
klaviyo.Coupons.get_coupon(id, fields_coupon=fields_coupon)
klaviyo.Coupons.get_coupon_code(id, fields_coupon_code=fields_coupon_code, fields_coupon=fields_coupon, include=include)
klaviyo.Coupons.get_coupon_codes(fields_coupon_code=fields_coupon_code, fields_coupon=fields_coupon, filter=filter, include=include, page_cursor=page_cursor)
klaviyo.Coupons.get_coupon_codes_for_coupon(id, fields_coupon_code=fields_coupon_code, filter=filter, page_cursor=page_cursor)
Method alias:
klaviyo.Coupons.get_coupon_coupon_codes(id, fields_coupon_code=fields_coupon_code, filter=filter, page_cursor=page_cursor)
klaviyo.Coupons.get_coupon_for_coupon_code(id, fields_coupon=fields_coupon)
Method alias:
klaviyo.Coupons.get_coupon_code_coupon(id, fields_coupon=fields_coupon)
klaviyo.Coupons.get_coupon_id_for_coupon_code(id)
Method alias:
klaviyo.Coupons.get_coupon_relationships_coupon_codes(id)
klaviyo.Coupons.get_coupons(fields_coupon=fields_coupon, page_cursor=page_cursor)
klaviyo.Coupons.update_coupon(id, body)
klaviyo.Coupons.update_coupon_code(id, body)
Data_Privacy
klaviyo.Data_Privacy.request_profile_deletion(body)
Method alias:
klaviyo.Data_Privacy.create_data_privacy_deletion_job(body)
Events
klaviyo.Events.bulk_create_events(body)
Method alias:
klaviyo.Events.create_event_bulk_create_job(body)
klaviyo.Events.create_event(body)
klaviyo.Events.get_event(id, fields_event=fields_event, fields_metric=fields_metric, fields_profile=fields_profile, include=include)
klaviyo.Events.get_event_metric(id, fields_metric=fields_metric)
klaviyo.Events.get_event_profile(id, additional_fields_profile=additional_fields_profile, fields_profile=fields_profile)
klaviyo.Events.get_events(fields_event=fields_event, fields_metric=fields_metric, fields_profile=fields_profile, filter=filter, include=include, page_cursor=page_cursor, sort=sort)
klaviyo.Events.get_metric_id_for_event(id)
Method alias:
klaviyo.Events.get_event_relationships_metric(id)
klaviyo.Events.get_profile_id_for_event(id)
Method alias:
klaviyo.Events.get_event_relationships_profile(id)
Flows
klaviyo.Flows.delete_flow(id)
klaviyo.Flows.get_action_id_for_flow_message(id)
Method alias:
klaviyo.Flows.get_flow_message_relationships_action(id)
klaviyo.Flows.get_action_ids_for_flow(id, filter=filter, page_size=page_size, sort=sort)
Method alias:
klaviyo.Flows.get_flow_relationships_flow_actions(id, filter=filter, page_size=page_size, sort=sort)
klaviyo.Flows.get_actions_for_flow(id, fields_flow_action=fields_flow_action, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Flows.get_flow_flow_actions(id, fields_flow_action=fields_flow_action, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Flows.get_flow(id, fields_flow_action=fields_flow_action, fields_flow=fields_flow, fields_tag=fields_tag, include=include)
klaviyo.Flows.get_flow_action(id, fields_flow_action=fields_flow_action, fields_flow_message=fields_flow_message, fields_flow=fields_flow, include=include)
klaviyo.Flows.get_flow_action_flow(id, fields_flow=fields_flow)
klaviyo.Flows.get_flow_id_for_flow_action(id)
Method alias:
klaviyo.Flows.get_flow_action_relationships_flow(id)
klaviyo.Flows.get_flow_message(id, fields_flow_action=fields_flow_action, fields_flow_message=fields_flow_message, fields_template=fields_template, include=include)
klaviyo.Flows.get_flow_message_action(id, fields_flow_action=fields_flow_action)
klaviyo.Flows.get_flow_tags(id, fields_tag=fields_tag)
klaviyo.Flows.get_flows(fields_flow_action=fields_flow_action, fields_flow=fields_flow, fields_tag=fields_tag, filter=filter, include=include, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Flows.get_message_ids_for_flow_action(id, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Flows.get_flow_action_relationships_messages(id, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Flows.get_messages_for_flow_action(id, fields_flow_message=fields_flow_message, filter=filter, page_size=page_size, sort=sort)
Method alias:
klaviyo.Flows.get_flow_action_messages(id, fields_flow_message=fields_flow_message, filter=filter, page_size=page_size, sort=sort)
klaviyo.Flows.get_tag_ids_for_flow(id)
Method alias:
klaviyo.Flows.get_flow_relationships_tags(id)
klaviyo.Flows.get_template_for_flow_message(id, fields_template=fields_template)
Method alias:
klaviyo.Flows.get_flow_message_template(id, fields_template=fields_template)
klaviyo.Flows.get_template_id_for_flow_message(id)
Method alias:
klaviyo.Flows.get_flow_message_relationships_template(id)
klaviyo.Flows.update_flow(id, body)
Forms
klaviyo.Forms.get_form(id, fields_form_version=fields_form_version, fields_form=fields_form, include=include)
klaviyo.Forms.get_form_for_form_version(id, fields_form=fields_form)
Method alias:
klaviyo.Forms.get_form_version_form(id, fields_form=fields_form)
klaviyo.Forms.get_form_id_for_form_version(id)
Method alias:
klaviyo.Forms.get_form_version_relationships_form(id)
klaviyo.Forms.get_form_version(id, fields_form_version=fields_form_version)
klaviyo.Forms.get_forms(fields_form=fields_form, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Forms.get_version_ids_for_form(id)
Method alias:
klaviyo.Forms.get_form_relationships_form_versions(id)
klaviyo.Forms.get_versions_for_form(id, fields_form_version=fields_form_version, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Forms.get_form_form_versions(id, fields_form_version=fields_form_version, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Images
klaviyo.Images.get_image(id, fields_image=fields_image)
klaviyo.Images.get_images(fields_image=fields_image, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Images.update_image(id, body)
klaviyo.Images.upload_image_from_file(file, name=name, hidden=hidden)
Method alias:
klaviyo.Images.create_image_upload(file, name=name, hidden=hidden)
klaviyo.Images.upload_image_from_url(body)
Method alias:
klaviyo.Images.create_image(body)
Lists
klaviyo.Lists.create_list(body)
klaviyo.Lists.create_list_relationships(id, body)
Method alias:
klaviyo.Lists.create_list_relationships_profile(id, body)
klaviyo.Lists.delete_list(id)
klaviyo.Lists.delete_list_relationships(id, body)
Method alias:
klaviyo.Lists.delete_list_relationships_profiles(id, body)
klaviyo.Lists.get_list(id, additional_fields_list=additional_fields_list, fields_flow=fields_flow, fields_list=fields_list, fields_tag=fields_tag, include=include)
klaviyo.Lists.get_list_flow_triggers(id, fields_flow=fields_flow)
klaviyo.Lists.get_list_profiles(id, additional_fields_profile=additional_fields_profile, fields_profile=fields_profile, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Lists.get_list_relationships_flow_triggers(id)
klaviyo.Lists.get_list_tags(id, fields_tag=fields_tag)
klaviyo.Lists.get_lists(fields_flow=fields_flow, fields_list=fields_list, fields_tag=fields_tag, filter=filter, include=include, page_cursor=page_cursor, sort=sort)
klaviyo.Lists.get_profile_ids_for_list(id, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Lists.get_list_relationships_profiles(id, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Lists.get_tag_ids_for_list(id)
Method alias:
klaviyo.Lists.get_list_relationships_tags(id)
klaviyo.Lists.update_list(id, body)
Metrics
klaviyo.Metrics.get_metric(id, fields_flow=fields_flow, fields_metric=fields_metric, include=include)
klaviyo.Metrics.get_metric_flow_triggers(id, fields_flow=fields_flow)
klaviyo.Metrics.get_metric_for_metric_property(id, fields_metric=fields_metric)
Method alias:
klaviyo.Metrics.get_metric_property_metric(id, fields_metric=fields_metric)
klaviyo.Metrics.get_metric_id_for_metric_property(id)
Method alias:
klaviyo.Metrics.get_metric_property_relationships_metric(id)
klaviyo.Metrics.get_metric_property(id, additional_fields_metric_property=additional_fields_metric_property, fields_metric_property=fields_metric_property, fields_metric=fields_metric, include=include)
klaviyo.Metrics.get_metric_relationships_flow_triggers(id)
klaviyo.Metrics.get_metrics(fields_flow=fields_flow, fields_metric=fields_metric, filter=filter, include=include, page_cursor=page_cursor)
klaviyo.Metrics.get_properties_for_metric(id, additional_fields_metric_property=additional_fields_metric_property, fields_metric_property=fields_metric_property)
Method alias:
klaviyo.Metrics.get_metric_metric_properties(id, additional_fields_metric_property=additional_fields_metric_property, fields_metric_property=fields_metric_property)
klaviyo.Metrics.get_property_ids_for_metric(id)
Method alias:
klaviyo.Metrics.get_metric_relationships_metric_properties(id)
klaviyo.Metrics.query_metric_aggregates(body)
Method alias:
klaviyo.Metrics.create_metric_aggregate(body)
Profiles
klaviyo.Profiles.bulk_subscribe_profiles(body)
Method alias:
klaviyo.Profiles.subscribe_profiles(body)
Method alias:
klaviyo.Profiles.create_profile_subscription_bulk_create_job(body)
klaviyo.Profiles.bulk_suppress_profiles(body)
Method alias:
klaviyo.Profiles.suppress_profiles(body)
Method alias:
klaviyo.Profiles.create_profile_suppression_bulk_create_job(body)
klaviyo.Profiles.bulk_unsubscribe_profiles(body)
Method alias:
klaviyo.Profiles.unsubscribe_profiles(body)
Method alias:
klaviyo.Profiles.create_profile_subscription_bulk_delete_job(body)
klaviyo.Profiles.bulk_unsuppress_profiles(body)
Method alias:
klaviyo.Profiles.unsuppress_profiles(body)
Method alias:
klaviyo.Profiles.create_profile_suppression_bulk_delete_job(body)
klaviyo.Profiles.create_or_update_profile(body, additional_fields_profile=additional_fields_profile)
Method alias:
klaviyo.Profiles.create_profile_import(body, additional_fields_profile=additional_fields_profile)
klaviyo.Profiles.create_profile(body, additional_fields_profile=additional_fields_profile)
klaviyo.Profiles.create_push_token(body)
klaviyo.Profiles.get_bulk_import_profiles_job(job_id, fields_list=fields_list, fields_profile_bulk_import_job=fields_profile_bulk_import_job, include=include)
Method alias:
klaviyo.Profiles.get_bulk_profile_import_job(job_id, fields_list=fields_list, fields_profile_bulk_import_job=fields_profile_bulk_import_job, include=include)
Method alias:
klaviyo.Profiles.get_profile_bulk_import_job(job_id, fields_list=fields_list, fields_profile_bulk_import_job=fields_profile_bulk_import_job, include=include)
klaviyo.Profiles.get_bulk_import_profiles_jobs(fields_profile_bulk_import_job=fields_profile_bulk_import_job, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Profiles.get_bulk_profile_import_jobs(fields_profile_bulk_import_job=fields_profile_bulk_import_job, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Profiles.get_profile_bulk_import_jobs(fields_profile_bulk_import_job=fields_profile_bulk_import_job, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Profiles.get_bulk_suppress_profiles_job(job_id, fields_profile_suppression_bulk_create_job=fields_profile_suppression_bulk_create_job)
Method alias:
klaviyo.Profiles.get_profile_suppression_bulk_create_job(job_id, fields_profile_suppression_bulk_create_job=fields_profile_suppression_bulk_create_job)
klaviyo.Profiles.get_bulk_suppress_profiles_jobs(fields_profile_suppression_bulk_create_job=fields_profile_suppression_bulk_create_job, filter=filter, page_cursor=page_cursor, sort=sort)
Method alias:
klaviyo.Profiles.get_profile_suppression_bulk_create_jobs(fields_profile_suppression_bulk_create_job=fields_profile_suppression_bulk_create_job, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Profiles.get_bulk_unsuppress_profiles_job(job_id, fields_profile_suppression_bulk_delete_job=fields_profile_suppression_bulk_delete_job)
Method alias:
klaviyo.Profiles.get_profile_suppression_bulk_delete_job(job_id, fields_profile_suppression_bulk_delete_job=fields_profile_suppression_bulk_delete_job)
klaviyo.Profiles.get_bulk_unsuppress_profiles_jobs(fields_profile_suppression_bulk_delete_job=fields_profile_suppression_bulk_delete_job, filter=filter, page_cursor=page_cursor, sort=sort)
Method alias:
klaviyo.Profiles.get_profile_suppression_bulk_delete_jobs(fields_profile_suppression_bulk_delete_job=fields_profile_suppression_bulk_delete_job, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Profiles.get_errors_for_bulk_import_profiles_job(id, fields_import_error=fields_import_error, page_cursor=page_cursor, page_size=page_size)
Method alias:
klaviyo.Profiles.get_bulk_profile_import_job_import_errors(id, fields_import_error=fields_import_error, page_cursor=page_cursor, page_size=page_size)
Method alias:
klaviyo.Profiles.get_profile_bulk_import_job_import_errors(id, fields_import_error=fields_import_error, page_cursor=page_cursor, page_size=page_size)
klaviyo.Profiles.get_list_for_bulk_import_profiles_job(id, fields_list=fields_list)
Method alias:
klaviyo.Profiles.get_bulk_profile_import_job_lists(id, fields_list=fields_list)
Method alias:
klaviyo.Profiles.get_profile_bulk_import_job_lists(id, fields_list=fields_list)
klaviyo.Profiles.get_list_ids_for_bulk_import_profiles_job(id)
Method alias:
klaviyo.Profiles.get_bulk_profile_import_job_relationships_lists(id)
Method alias:
klaviyo.Profiles.get_profile_bulk_import_job_relationships_lists(id)
klaviyo.Profiles.get_list_ids_for_profile(id)
Method alias:
klaviyo.Profiles.get_profile_relationships_lists(id)
klaviyo.Profiles.get_lists_for_profile(id, fields_list=fields_list)
Method alias:
klaviyo.Profiles.get_profile_lists(id, fields_list=fields_list)
klaviyo.Profiles.get_profile(id, additional_fields_profile=additional_fields_profile, fields_list=fields_list, fields_profile=fields_profile, fields_segment=fields_segment, include=include)
klaviyo.Profiles.get_profile_ids_for_bulk_import_profiles_job(id, page_cursor=page_cursor, page_size=page_size)
Method alias:
klaviyo.Profiles.get_bulk_profile_import_job_relationships_profiles(id, page_cursor=page_cursor, page_size=page_size)
Method alias:
klaviyo.Profiles.get_profile_bulk_import_job_relationships_profiles(id, page_cursor=page_cursor, page_size=page_size)
klaviyo.Profiles.get_profiles(additional_fields_profile=additional_fields_profile, fields_profile=fields_profile, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Profiles.get_profiles_for_bulk_import_profiles_job(id, additional_fields_profile=additional_fields_profile, fields_profile=fields_profile, page_cursor=page_cursor, page_size=page_size)
Method alias:
klaviyo.Profiles.get_bulk_profile_import_job_profiles(id, additional_fields_profile=additional_fields_profile, fields_profile=fields_profile, page_cursor=page_cursor, page_size=page_size)
Method alias:
klaviyo.Profiles.get_profile_bulk_import_job_profiles(id, additional_fields_profile=additional_fields_profile, fields_profile=fields_profile, page_cursor=page_cursor, page_size=page_size)
klaviyo.Profiles.get_segment_ids_for_profile(id)
Method alias:
klaviyo.Profiles.get_profile_relationships_segments(id)
klaviyo.Profiles.get_segments_for_profile(id, fields_segment=fields_segment)
Method alias:
klaviyo.Profiles.get_profile_segments(id, fields_segment=fields_segment)
klaviyo.Profiles.merge_profiles(body)
Method alias:
klaviyo.Profiles.create_profile_merge(body)
klaviyo.Profiles.spawn_bulk_profile_import_job(body)
Method alias:
klaviyo.Profiles.bulk_import_profiles(body)
Method alias:
klaviyo.Profiles.create_profile_bulk_import_job(body)
klaviyo.Profiles.update_profile(id, body, additional_fields_profile=additional_fields_profile)
Reporting
klaviyo.Reporting.query_campaign_values(body, page_cursor=page_cursor)
Method alias:
klaviyo.Reporting.create_campaign_value_report(body, page_cursor=page_cursor)
klaviyo.Reporting.query_flow_series(body, page_cursor=page_cursor)
Method alias:
klaviyo.Reporting.create_flow_sery_report(body, page_cursor=page_cursor)
klaviyo.Reporting.query_flow_values(body, page_cursor=page_cursor)
Method alias:
klaviyo.Reporting.create_flow_value_report(body, page_cursor=page_cursor)
klaviyo.Reporting.query_form_series(body)
Method alias:
klaviyo.Reporting.create_form_sery_report(body)
klaviyo.Reporting.query_form_values(body)
Method alias:
klaviyo.Reporting.create_form_value_report(body)
klaviyo.Reporting.query_segment_series(body)
Method alias:
klaviyo.Reporting.create_segment_sery_report(body)
klaviyo.Reporting.query_segment_values(body)
Method alias:
klaviyo.Reporting.create_segment_value_report(body)
Reviews
klaviyo.Reviews.get_review(id, fields_event=fields_event, fields_review=fields_review, include=include)
klaviyo.Reviews.get_reviews(fields_event=fields_event, fields_review=fields_review, filter=filter, include=include, page_cursor=page_cursor, page_size=page_size, sort=sort)
Segments
klaviyo.Segments.create_segment(body)
klaviyo.Segments.delete_segment(id)
klaviyo.Segments.get_profile_ids_for_segment(id, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Segments.get_segment_relationships_profiles(id, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Segments.get_profiles_for_segment(id, additional_fields_profile=additional_fields_profile, fields_profile=fields_profile, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Segments.get_segment_profiles(id, additional_fields_profile=additional_fields_profile, fields_profile=fields_profile, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Segments.get_segment(id, additional_fields_segment=additional_fields_segment, fields_flow=fields_flow, fields_segment=fields_segment, fields_tag=fields_tag, include=include)
klaviyo.Segments.get_segment_flow_triggers(id, fields_flow=fields_flow)
klaviyo.Segments.get_segment_relationships_flow_triggers(id)
klaviyo.Segments.get_segments(fields_flow=fields_flow, fields_segment=fields_segment, fields_tag=fields_tag, filter=filter, include=include, page_cursor=page_cursor, sort=sort)
klaviyo.Segments.get_tag_ids_for_segment(id)
Method alias:
klaviyo.Segments.get_segment_relationships_tags(id)
klaviyo.Segments.get_tags_for_segment(id, fields_tag=fields_tag)
Method alias:
klaviyo.Segments.get_segment_tags(id, fields_tag=fields_tag)
klaviyo.Segments.update_segment(id, body)
Tags
klaviyo.Tags.create_tag(body)
klaviyo.Tags.create_tag_group(body)
klaviyo.Tags.delete_tag(id)
klaviyo.Tags.delete_tag_group(id)
klaviyo.Tags.get_campaign_ids_for_tag(id)
Method alias:
klaviyo.Tags.get_tag_relationships_campaigns(id)
klaviyo.Tags.get_flow_ids_for_tag(id)
Method alias:
klaviyo.Tags.get_tag_relationships_flows(id)
klaviyo.Tags.get_list_ids_for_tag(id)
Method alias:
klaviyo.Tags.get_tag_relationships_lists(id)
klaviyo.Tags.get_segment_ids_for_tag(id)
Method alias:
klaviyo.Tags.get_tag_relationships_segments(id)
klaviyo.Tags.get_tag(id, fields_tag_group=fields_tag_group, fields_tag=fields_tag, include=include)
klaviyo.Tags.get_tag_group(id, fields_tag_group=fields_tag_group)
klaviyo.Tags.get_tag_group_for_tag(id, fields_tag_group=fields_tag_group)
Method alias:
klaviyo.Tags.get_tag_tag_group(id, fields_tag_group=fields_tag_group)
klaviyo.Tags.get_tag_group_id_for_tag(id)
Method alias:
klaviyo.Tags.get_tag_relationships_tag_group(id)
klaviyo.Tags.get_tag_groups(fields_tag_group=fields_tag_group, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Tags.get_tag_ids_for_tag_group(id)
Method alias:
klaviyo.Tags.get_tag_group_relationships_tags(id)
klaviyo.Tags.get_tags(fields_tag_group=fields_tag_group, fields_tag=fields_tag, filter=filter, include=include, page_cursor=page_cursor, sort=sort)
klaviyo.Tags.get_tags_for_tag_group(id, fields_tag=fields_tag)
Method alias:
klaviyo.Tags.get_tag_group_tags(id, fields_tag=fields_tag)
klaviyo.Tags.remove_tag_from_campaigns(id, body)
Method alias:
klaviyo.Tags.delete_tag_relationships_campaigns(id, body)
klaviyo.Tags.remove_tag_from_flows(id, body)
Method alias:
klaviyo.Tags.delete_tag_relationships_flows(id, body)
klaviyo.Tags.remove_tag_from_lists(id, body)
Method alias:
klaviyo.Tags.delete_tag_relationships_lists(id, body)
klaviyo.Tags.remove_tag_from_segments(id, body)
Method alias:
klaviyo.Tags.delete_tag_relationships_segments(id, body)
klaviyo.Tags.tag_campaigns(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_campaigns(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_campaign(id, body)
klaviyo.Tags.tag_flows(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_flows(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_flow(id, body)
klaviyo.Tags.tag_lists(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_lists(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_list(id, body)
klaviyo.Tags.tag_segments(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_segments(id, body)
Method alias:
klaviyo.Tags.create_tag_relationships_segment(id, body)
klaviyo.Tags.update_tag(id, body)
klaviyo.Tags.update_tag_group(id, body)
Templates
klaviyo.Templates.clone_template(body)
Method alias:
klaviyo.Templates.create_template_clone(body)
klaviyo.Templates.create_template(body)
klaviyo.Templates.create_universal_content(body)
Method alias:
klaviyo.Templates.create_template_universal_content(body)
klaviyo.Templates.delete_template(id)
klaviyo.Templates.delete_universal_content(id)
Method alias:
klaviyo.Templates.delete_template_universal_content(id)
klaviyo.Templates.get_all_universal_content(fields_template_universal_content=fields_template_universal_content, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
Method alias:
klaviyo.Templates.get_template_universal_content(fields_template_universal_content=fields_template_universal_content, filter=filter, page_cursor=page_cursor, page_size=page_size, sort=sort)
klaviyo.Templates.get_template(id, fields_template=fields_template)
klaviyo.Templates.get_templates(fields_template=fields_template, filter=filter, page_cursor=page_cursor, sort=sort)
klaviyo.Templates.get_universal_content(id, fields_template_universal_content=fields_template_universal_content)
klaviyo.Templates.render_template(body)
Method alias:
klaviyo.Templates.create_template_render(body)
klaviyo.Templates.update_template(id, body)
klaviyo.Templates.update_universal_content(id, body)
Method alias:
klaviyo.Templates.update_template_universal_content(id, body)
Tracking_Settings
klaviyo.Tracking_Settings.get_tracking_setting(id, fields_tracking_setting=fields_tracking_setting)
klaviyo.Tracking_Settings.get_tracking_settings(fields_tracking_setting=fields_tracking_setting, page_cursor=page_cursor, page_size=page_size)
klaviyo.Tracking_Settings.update_tracking_setting(id, body)
Webhooks
klaviyo.Webhooks.create_webhook(body)
klaviyo.Webhooks.delete_webhook(id)
klaviyo.Webhooks.get_webhook(id, fields_webhook=fields_webhook, include=include)
klaviyo.Webhooks.get_webhook_topic(id)
klaviyo.Webhooks.get_webhook_topics()
klaviyo.Webhooks.get_webhooks(fields_webhook=fields_webhook, include=include)
klaviyo.Webhooks.update_webhook(id, body)
Appendix
Global Keyword Args
NOTE: These are arguments that you can apply to any endpoint call, and which are unique to the SDK
We currently support the following global keyword args:
_request_auth
: use this to override the client-level api_key which you define upon client instantiation
Refresher on catching exceptions:
try:
YOUR_CALL
except Exception as e:
print(e.status)
print(e.reason)
print(e.body)
print(e.headers)
Parameters & Arguments
The parameters follow the same naming conventions as the resource groups and operations.
We stick to the following convention for parameters/arguments
- All parameters are passed as function args.
- All query and path params that are tagged as
required
in the docs are passed as positional args. - All optional query params are passed as keyword args.
- Where applicable, the
body
param is passed in as a positional arg, and is expected to be a native python dictionary. Within that dictionary, refer to the API docs to see which fields are required/optional, along with valid values. - There is no need to pass in your private
api_key
for any operations, as it is defined upon client instantiation; public key is still required where applicable. However, you can pass in an optional _request_auth
kwarg to override the client private key for a specific call (REMINDER: don't do this client-side).
Namespace
In the interest of making the SDK Pythonic, we made the following namespace changes relative to the language agnostic resources up top (API Docs, Guides, etc).
- Resource names use Title + Snake Casing, (e.g.
Data_Privacy
) - function names and parameter names use snake case (e.g.
get_metrics
, and profile_id
)
Renamed Fields
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.
class StaticScheduleOptions(BaseModel):
"""
StaticScheduleOptions
"""
datetime_: datetime = Field(description="The time to send at", alias="datetime")
Usage
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_)
Filter Builder
Use this class to help construct filter query parameters.
old_date = datetime.datetime(2023, 8, 15, 12, 30, 0, 0, tzinfo=datetime.timezone.utc)
f = FilterBuilder()
f.any("email", ["sarah.mason@klaviyo-demo.com", "sm@klaviyo-demo.com"])
f.greater_than("created", old_date)
profile_response = client.Profiles.get_profiles(filter=f.build())
f = FilterBuilder()
filters = f.any("email", ["sarah.mason@klaviyo-demo.com", "sm@klaviyo-demo.com"]).greater_than("created", date).build()
assert filters == "any(email,['sarah.mason@klaviyo-demo.com','sm@klaviyo-demo.com']),greater-than(created,2023-08-15T12:30:00+00:00)"
Typed Responses
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:
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__)
The class used in this example is found here.
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 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:
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
)
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']
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.
Untyped Response Data for Specific APIs
Select APIs do not yet have fully typed responses. Please use our API docs to inspect the schema of the response data for the following APIs.
- Segments - The subproperty
conditions
is not yet typed in responses for the following APIs:
- The
included
property is not typed in responses for the following APIs:
- The
tracking_options
subproperty is not typed in responses for the following APIs:
- The
send_options
subproperty is not typed in responses for the following APIs:
- The
content
subproperty is not typed in responses for the following APIs:
Lazy Imports
If the klaviyo_api
import has a long load time, you can set the following environment variable to speed it up:
export KLAVIYO_PYTHON_SDK_LAZY_IMPORTS=true
With this, API classes and models will be imported per-API (e.g. when you use the Profiles API, it only imports profiles-related classes).
With this setting, you can no longer tersely import from openapi_client
. That is, instead of:
from openapi_client import CampaignCreateQuery
you will need:
from openapi_client.models.campaign_create_query import CampaignCreateQuery