Klaviyo

Klaviyo API integration with managed OAuth. Access profiles, lists, segments, campaigns, flows

Klaviyo is a community skill for email marketing automation and customer data management, covering profile and list management, segment creation and targeting, campaign orchestration, flow automation, and event tracking for data-driven marketing workflows.

What Is This?

Overview

Klaviyo provides AI agents with access to email marketing and customer data platform capabilities through a managed OAuth integration. It covers profile management that creates, updates, and searches customer profiles with custom attributes and tags, list operations that organize contacts into static and dynamic segments for targeted campaigns, segment creation that builds audience groups based on behavioral and demographic criteria, campaign orchestration that schedules and sends email campaigns with template support and performance tracking, and event tracking that logs customer actions like purchases, page views, and custom events for personalization. The skill helps marketing teams automate customer engagement workflows.

Who Should Use This

This skill serves marketing automation developers building email campaign systems, e-commerce teams integrating customer data platforms, and AI agents managing personalized customer communications.

Why Use It?

Problems It Solves

Managing email marketing campaigns manually through web interfaces is time-consuming and error-prone when handling large customer lists. Building custom integrations with Klaviyo requires OAuth setup, API pagination handling, and error management boilerplate code. Synchronizing customer data between e-commerce platforms and marketing systems involves complex data transformation and validation logic. Triggering automated email flows based on customer behavior requires event tracking infrastructure and real-time data processing capabilities.

Core Highlights

Profile manager creates, updates, and searches customer profiles with custom attributes. List controller organizes contacts into segments for targeted campaigns. Campaign orchestrator schedules and sends emails with template support. Event tracker logs customer actions for personalization and flow triggers.

How to Use It?

Basic Usage

import os
import requests

api_key = os.environ[
    'KLAVIYO_API_KEY']
headers = {
    'Authorization':
        f'Klaviyo-API-Key'
        f' {api_key}',
    'revision':
        '2024-02-15'
}

resp = requests.get(
    'https://a.klaviyo.com'
    '/api/profiles',
    headers=headers,
    params={'page[size]': 10}
)
profiles = resp.json()[
    'data']
for p in profiles:
    print(
        p['attributes']
        ['email'])

Real-World Examples

profile_data = {
    'data': {
        'type': 'profile',
        'attributes': {
            'email':
                'user@example.com',
            'first_name': 'Jane',
            'properties': {
                'plan': 'premium'
            }
        }
    }
}
requests.post(
    'https://a.klaviyo.com'
    '/api/profiles',
    headers=headers,
    json=profile_data)

event_data = {
    'data': {
        'type': 'event',
        'attributes': {
            'metric': {
                'data': {
                    'type': 'metric',
                    'attributes':
                        {'name':
                         'Purchase'}
                }
            },
            'profile': {
                'data': {
                    'type': 'profile',
                    'attributes':
                        {'email':
                         'user@'
                         'example.com'}
                }
            },
            'value': 99.99
        }
    }
}
requests.post(
    'https://a.klaviyo.com'
    '/api/events',
    headers=headers,
    json=event_data)

Advanced Tips

Use the segments endpoint to build dynamic audiences based on profile properties and event history for personalized campaigns. Implement webhook handlers to receive real-time notifications when profiles are updated or campaigns are sent. Leverage the metrics endpoint to track email performance and optimize campaign timing and content based on engagement data.

When to Use It?

Use Cases

Automate email campaign creation and scheduling based on customer segments and behavior triggers. Synchronize customer data between e-commerce platforms and Klaviyo for unified marketing automation. Build AI agents that send personalized emails when customers reach specific milestones or complete key actions.

Related Topics

Email marketing automation, customer data platforms, behavioral segmentation, campaign orchestration, event tracking, and marketing APIs.

Important Notes

Requirements

A Klaviyo account with API access enabled and a private API key configured in environment variables. OAuth credentials for managed authentication if using the ClawHub integration layer. Network access to Klaviyo API endpoints for profile, list, campaign, and event operations.

Usage Recommendations

Do: use revision headers to ensure API compatibility and avoid breaking changes. Implement pagination for large profile and event queries to handle all results. Validate email addresses before creating profiles to maintain list quality.

Don't: send API keys in query parameters or log them in plain text since they grant full account access. Create duplicate profiles for the same email address without checking existence first. Exceed API rate limits by making too many concurrent requests without backoff logic.

Limitations

Klaviyo API has rate limits that vary by account tier and endpoint, potentially throttling high-volume operations. Some advanced features like A/B testing and advanced flow logic may require web interface configuration. Event data may have a short delay before appearing in segments and reports due to processing latency.