> ## Documentation Index
> Fetch the complete documentation index at: https://docs.helloleo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Klaviyo Integration

> Connect HelloLeo to your Klaviyo marketing platform

Connect HelloLeo to your Klaviyo account to manage profiles, lists, campaigns, and marketing automation.

## Setup

1. Go to **Project Settings** → **Project Integrations**
2. Select **Klaviyo** from the list
3. Enter your credentials:
   * **Private API Key** - Your Klaviyo Private API Key
     * Get it from [Klaviyo API Keys](https://www.klaviyo.com/settings/account/api-keys)
4. Test the connection
5. Start using Klaviyo in your prompts

## How It Works

HelloLeo uses the Klaviyo API through the Integration Proxy. Your private API key is encrypted and stored securely on the backend. API calls are made directly from your frontend through the proxy, avoiding CORS issues.

## API Endpoints

The integration uses Klaviyo's REST API (revision 2024-10-15). Endpoints follow the format:

* `/api/profiles/` - Manage customer profiles
* `/api/lists/` - Manage email lists
* `/api/campaigns/` - Manage campaigns
* `/api/events/` - Track events
* `/api/metrics/` - Access metrics

## Common Operations

### List Profiles

* **GET** `/api/profiles/` - List customer profiles
* Supports query parameters: `page[size]`, `page[cursor]`, `filter`, `sort`, `fields`

### Create Profiles

* **POST** `/api/profiles/` - Create a new customer profile

### Update Profiles

* **PATCH** `/api/profiles/{profile_id}/` - Update a profile

### List Lists

* **GET** `/api/lists/` - List email lists

### Create Lists

* **POST** `/api/lists/` - Create a new email list

## Query Parameters

When listing resources, you can use:

* **page\[size]** - Number of items per page
* **page\[cursor]** - Cursor for pagination
* **filter** - Filter results (e.g., `equals(email,test@example.com)`)
* **sort** - Sort results (e.g., `created_at`)
* **fields** - Specify which fields to return (comma-separated or array)

## Example Usage

### Display Profiles

```
Show all profiles from Klaviyo. Display email, first name, 
last name, and subscription status.
```

### Create a Profile

```
Create a new profile in Klaviyo with email "customer@example.com", 
first name "John", and last name "Doe".
```

### Search Profiles

```
Find all profiles in Klaviyo where the email contains "example.com".
```

### Update a Profile

```
Update the Klaviyo profile for "customer@example.com" to set 
their subscription status to "subscribed".
```

### Manage Lists

```
Show all email lists in Klaviyo and display the number of 
subscribers in each list.
```

## Best Practices

* **Specify fields** - Tell Leo which fields to display or update
* **Use filters** - Describe what profiles you want to find
* **Mention the integration** - Always say "from Klaviyo" or "to Klaviyo" so Leo knows which integration to use
* **Use pagination** - For large datasets, specify page size

## Troubleshooting

### Connection Issues

* **Check API key** - Verify your Private API Key is correct
* **Key permissions** - Ensure your API key has the necessary permissions
* **API revision** - The integration uses Klaviyo API revision 2024-10-15

### Data Not Showing

* **Check endpoint** - Verify you're using the correct API endpoint
* **Permissions** - Ensure your API key has read access
* **Filter syntax** - Review your filter criteria

### Can't Create/Update

* **Write permissions** - Ensure your API key has write access
* **Required fields** - Check that all required fields are provided
* **Data format** - Verify data matches Klaviyo's expected format

<CardGroup cols={2}>
  <Card title="Working with Integrations" icon="plug" href="/integrations/working-with-integrations">
    Learn how to use integrations effectively
  </Card>

  <Card title="Network Monitor" icon="activity" href="/features/network-monitor">
    Debug Klaviyo API calls
  </Card>
</CardGroup>
