PHPackages                             klaviyo/php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. klaviyo/php-sdk

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

klaviyo/php-sdk
===============

Klaviyo PHP SDK

2.3.6(4y ago)601.4M↓17.1%45[5 PRs](https://github.com/klaviyo/php-klaviyo/pulls)1Apache-2.0PHPPHP &gt;=5.6

Since Aug 2Pushed 2y ago95 watchersCompare

[ Source](https://github.com/klaviyo/php-klaviyo)[ Packagist](https://packagist.org/packages/klaviyo/php-sdk)[ Docs](http://github.com/klaviyo)[ RSS](/packages/klaviyo-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (21)Used By (1)

php-klaviyo - RETIRED
=====================

[](#php-klaviyo---retired)

Deprecation Notice
==================

[](#deprecation-notice)

This SDK and its associated pip package are set to be deprecated on 2024-06-30 and will not receive further updates.

We recommend migrating over to our [newest SDK](https://github.com/klaviyo/klaviyo-api-php).

You can read more about our SDK release history and support [here](https://developers.klaviyo.com/en/docs/sdk_overview)

For a comparison between our old and new APIs, check out [this guide](https://developers.klaviyo.com/en/docs/apis_comparison_chart).

Migration Instructions
----------------------

[](#migration-instructions)

NOTE: this change is not backwards compatible; migrating to the new SDK requires completing the following steps:

### Install New SDK

[](#install-new-sdk)

`composer require klaviyo/sdk`

### Update Import

[](#update-import)

From:

```
use Klaviyo\Klaviyo as Klaviyo;
```

To:

```
use Klaviyo\Client;
```

### Update Client Instantiation

[](#update-client-instantiation)

From:

```
$client = new Klaviyo( 'PRIVATE_API_KEY', 'PUBLIC_API_KEY' );
```

To:

```
$client = new Client('YOUR_API_KEY');
```

### Updating SDK Calls

[](#updating-sdk-calls)

The new SDK has many changes to namespace (resource and function names), parameters (names, types, and format), and error handling. Additionally, the new SDK sticks to just standard/built-in PHP types (int, string, array, etc), and does not make use of custom Models, as this legacy one does. Please reference [this section](https://github.com/klaviyo/klaviyo-php-sdk#comprehensive-list-of-operations--parameters) of the new SDK repo for details on how to update each operation.

### Multistore limitation

[](#multistore-limitation)

The new SDK currently sets API keys at a global environment level. This means that if you manage multiple stores, each store's client must be running in a different environment. We plan to update this behavior to better support multistore applications.

What is Klaviyo?
================

[](#what-is-klaviyo)

Klaviyo is a real-time service for understanding your customers by aggregating all your customer data, identifying important groups of customers and then taking action.

What does this package do?
--------------------------

[](#what-does-this-package-do)

- Track customers and events directly from your backend.

How to install?
---------------

[](#how-to-install)

```
composer require klaviyo/php-sdk

```

API Examples
------------

[](#api-examples)

After installing the Klaviyo package you can initiate it using your public token which is for track events or identifying profiles and/or your private api key to utilize the metrics and list apis.

```
use Klaviyo\Klaviyo as Klaviyo;

$client = new Klaviyo( 'PRIVATE_API_KEY', 'PUBLIC_API_KEY' );
```

You can then easily use Klaviyo to track events or identify people. Note, track and identify requests take your public token.

### Track an event

[](#track-an-event)

```
use Klaviyo\Model\EventModel as KlaviyoEvent;

$event = new KlaviyoEvent(
    array(
        'event' => 'Filled out Profile',
        'customer_properties' => array(
            '$email' => 'someone@mailinator.com'
        ),
        'properties' => array(
            'Added Social Accounts' => False
        )
    )
);

$client->publicAPI->track( $event, true );
```

### You can also add profile properties to the 'customer properties' attribute in the Event model

[](#you-can-also-add-profile-properties-to-the-customer-properties-attribute-in-the-event-model)

```
use Klaviyo\Model\EventModel as KlaviyoEvent;

$event = new KlaviyoEvent(
    array(
        'event' => 'Filled out Profile',
        'customer_properties' => array(
            '$email' => 'someone@mailinator.com',
            '$first_name' => 'Thomas',
            '$last_name' => 'Jefferson'
        ),
        'properties' => array(
            'Added Social Accounts' => False
        )
    )
);

$client->publicAPI->track( $event, true );
```

### or just add a property to someone

[](#or-just-add-a-property-to-someone)

```
use Klaviyo\Model\ProfileModel as KlaviyoProfile;

$profile = new KlaviyoProfile(
    array(
        '$email' => 'thomas.jefferson@mailinator.com',
        '$first_name' => 'Thomas',
        '$last_name' => 'Jefferson',
        'Plan' => 'Premium'
    )
);

$client->publicAPI->identify( $profile, true );
```

### You can get metrics, a timeline of events and export analytics for a metric. See here for more

[](#you-can-get-metrics-a-timeline-of-events-and-export-analytics-for-a-metric-see-here-for-more-httpswwwklaviyocomdocsapimetrics)

```
#return a list of all metrics in your Klaviyo account
$client->metrics->getMetrics();

#return a timeline of all metrics
$client->metrics->getMetricsTimeline();

#return a specific metric timeline using its metric ID
$client->metrics->getMetricTimelineById( 'METRICID' );

#export metric specific values
$client->metrics->getMetricExport( 'METRICID' );
```

### You can create, update, read, and delete lists. See here for more information

[](#you-can-create-update-read-and-delete-lists--see-here-for-more-information-httpswwwklaviyocomdocsapiv2lists)

```
#create a list
$client->lists->createList( 'List Name' );

#Get all lists in your Klaviyo account
$client->lists->getLists();

#Get information about a list
$client->lists->getListById( 'ListId' );

#update a lists properties
$client->lists->updateListNameById( 'ListId', 'ListName' );

#Delete a list from account
$client->lists->deleteList( 'ListId' );

#Subscribe or re-subscribe profiles to a list
$client->lists->addSubscribersToList( 'ListId', array $arrayOfProfiles );

#Check if profiles are on a list and not suppressed
$client->lists->checkListSubscriptions( 'ListId', array $emails, array $phoneNumbers, array $pushTokens );

#Unsubscribe and remove profiles from a list
$client->lists->deleteSubscribersFromList( 'ListId', array $emails );

#Add members to list without affecting consent status
$client->lists->addMembersToList( 'ListId', array $arrayOfProfiles );

#Check if profiles are on a list
$client->lists->checkListMembership( 'ListId', array $emails, array $phoneNumbers, array $pushTokens );

#Remove members from a list without changing their consent status
$client->lists->removeMembersFromList( 'ListId', array $emails );

#Get all exclusions on a list
$client->lists->getListExclusions( 'ListId' );

#Get all of the emails, phone numbers and push tokens for profiles in a given list or segment
$client->lists->getAllMembers( 'GroupId', $marker = $marker_value );
```

### You can fetch profile information given the profile ID, See here for more information

[](#you-can-fetch-profile-information-given-the-profile-id-see-here-for-more-information-httpswwwklaviyocomdocsapipeople)

```
#Get profile by profileId
$client->profiles->getProfile( 'ProfileId' );

#Update a profile
$client->profiles->updateProfile( 'ProfileId', array $properties );

#Get all metrics for a profile
$client->profiles->getAllProfileMetricsTimeline( 'ProfileId' );

#Get a specific metric for a profile
$client->profiles->getProfileMetricTimeline( 'ProfileId', 'MetricId' );

#Get a profile's ID by its email address
$client->profiles->getProfileIdByEmail('someone@mailinator.com');
```

### You can request a privacy-compliant profile deletion given an identifying property

[](#you-can-request-a-privacy-compliant-profile-deletion-given-an-identifying-property)

```
#Request profile deletion by email
$client->dataPrivacy->requestProfileDeletion('someone@mailinator.com');

#Request profile deletion by phone number
$client->dataPrivacy->requestProfileDeletion('1-234-567-8910', 'phone_number');

#Request profile deletion by person ID
$client->dataPrivacy->requestProfileDeletion('abc123', 'person_id');
```

Exceptions
----------

[](#exceptions)

### Klaviyo\\Exception\\KlaviyoApiException

[](#klaviyoexceptionklaviyoapiexception)

Thrown when there is an issue making an API request. After you catch this exception, you can use getMessage() and it will return a string containing more details about the issue that occurred.

### Klaviyo\\Exception\\KlaviyoRateLimitException

[](#klaviyoexceptionklaviyoratelimitexception)

If a rate limit happens it will throw a Klaviyo\\Exception\\KlaviyoRateLimitException. After you catch this exception you can use getMessage() and it will return a JSON encoded array: `{"detail":"Request was throttled. Expected available in 26.0 seconds.","retryAfter":26}`

### Klaviyo\\Exception\\KlaviyoAuthenticationException

[](#klaviyoexceptionklaviyoauthenticationexception)

Thrown when there is an authentication error when making an API request, usually caused by an invalid API key.

### Klaviyo\\Exception\\KlaviyoResourceNotFoundException

[](#klaviyoexceptionklaviyoresourcenotfoundexception)

Thrown when the system attempts to update a property that doesn't exist. For example, attempting to update a list that doesn't exist on the account.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~84 days

Recently: every ~75 days

Total

17

Last Release

1487d ago

Major Versions

1.0.0 → 2.0.12020-07-21

PHP version history (2 changes)1.0.0PHP &gt;=5.2.0

2.3.0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8abe9b3ef0724e0e16bac186b8bfcdcb67e034942299faba9cf0c704683abc1?d=identicon)[klaviyo](/maintainers/klaviyo)

---

Top Contributors

[![siddwarkhedkar](https://avatars.githubusercontent.com/u/32624393?v=4)](https://github.com/siddwarkhedkar "siddwarkhedkar (31 commits)")[![smoucka](https://avatars.githubusercontent.com/u/4282644?v=4)](https://github.com/smoucka "smoucka (30 commits)")[![remstone7](https://avatars.githubusercontent.com/u/16033088?v=4)](https://github.com/remstone7 "remstone7 (28 commits)")[![jon-batscha](https://avatars.githubusercontent.com/u/61248025?v=4)](https://github.com/jon-batscha "jon-batscha (10 commits)")[![ogsmith](https://avatars.githubusercontent.com/u/9705546?v=4)](https://github.com/ogsmith "ogsmith (7 commits)")[![kamil-klasicki](https://avatars.githubusercontent.com/u/31895163?v=4)](https://github.com/kamil-klasicki "kamil-klasicki (6 commits)")[![loevgaard](https://avatars.githubusercontent.com/u/2412177?v=4)](https://github.com/loevgaard "loevgaard (6 commits)")[![dano-klaviyo](https://avatars.githubusercontent.com/u/93663275?v=4)](https://github.com/dano-klaviyo "dano-klaviyo (5 commits)")[![bialecki](https://avatars.githubusercontent.com/u/131007?v=4)](https://github.com/bialecki "bialecki (4 commits)")[![etienneroudeix](https://avatars.githubusercontent.com/u/2012682?v=4)](https://github.com/etienneroudeix "etienneroudeix (2 commits)")[![mangoceylon2](https://avatars.githubusercontent.com/u/125075488?v=4)](https://github.com/mangoceylon2 "mangoceylon2 (1 commits)")[![invertedfjord](https://avatars.githubusercontent.com/u/8738506?v=4)](https://github.com/invertedfjord "invertedfjord (1 commits)")[![chris-ware](https://avatars.githubusercontent.com/u/19684457?v=4)](https://github.com/chris-ware "chris-ware (1 commits)")[![bradleymellen](https://avatars.githubusercontent.com/u/34170427?v=4)](https://github.com/bradleymellen "bradleymellen (1 commits)")[![syammohanmp](https://avatars.githubusercontent.com/u/3455064?v=4)](https://github.com/syammohanmp "syammohanmp (1 commits)")[![cykolln](https://avatars.githubusercontent.com/u/78871498?v=4)](https://github.com/cykolln "cykolln (1 commits)")

---

Tags

sdkklaviyo

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/klaviyo-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/klaviyo-php-sdk/health.svg)](https://phpackages.com/packages/klaviyo-php-sdk)
```

###  Alternatives

[aws/aws-crt-php

AWS Common Runtime for PHP

420300.1M4](/packages/aws-aws-crt-php)[zumba/amplitude-php

PHP SDK for Amplitude

409.5M5](/packages/zumba-amplitude-php)[ennnnny/tbk

简约优雅的淘宝客SDK

29016.1k1](/packages/ennnnny-tbk)[anilcancakir/laravel-ai-sdk-skills

A skill system for Laravel AI SDK agents. Define reusable AI capabilities with SKILL.md files.

151.1k](/packages/anilcancakir-laravel-ai-sdk-skills)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
