PHPackages                             sendboo/sendboo-php - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. sendboo/sendboo-php

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

sendboo/sendboo-php
===================

Framework-agnostic PHP client for the Sendboo API: track events and sync subscribers from any website.

v0.1.0(yesterday)00MITPHPPHP ^8.1

Since Jun 18Pushed yesterdayCompare

[ Source](https://github.com/Dricle/sendboo-php)[ Packagist](https://packagist.org/packages/sendboo/sendboo-php)[ RSS](/packages/sendboo-sendboo-php/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

sendboo-php
===========

[](#sendboo-php)

PHP client for the [Sendboo](https://sendboo.com) API. Track events and sync subscribers from any website.

Install
-------

[](#install)

```
composer require sendboo/sendboo-php
```

Authenticate
------------

[](#authenticate)

You need a Sendboo API token plus your organization (and store) UUIDs. They map to the `Authorization: Bearer`, `X-Organization-Id` and `X-Store-Id` headers the API expects.

```
use Sendboo\Sendboo;

$sendboo = new Sendboo(
    token:          '123|sb_...',
    organizationId: 'org-uuid',
    storeId:        'store-uuid', // optional; required for events & subscribers
);
```

Track events
------------

[](#track-events)

Identify the actor with an `anonymous_id` (a visitor id you generate) or a `subscriber_id`. `source` defaults to `php` and `occurred_at` to now.

```
$sendboo->track('purchase_completed', [
    'anonymous_id' => $visitorId,
    'properties'   => ['order_id' => 1234, 'total' => 79.90],
]);
```

Sync subscribers
----------------

[](#sync-subscribers)

`sync()` upserts every row into a Sendboo email list. Pass `unsubscribeMissing: true` to also unsubscribe people who are on the list but no longer in your data (drift removal, off by default because it's destructive).

```
// Build the list however you fetch subscribers — here from a plain PDO query.
$rows = [];

foreach ($pdo->query('SELECT email, first_name, plan FROM users WHERE subscribed = 1') as $user) {
    $rows[] = [
        'email'      => $user['email'],
        'first_name' => $user['first_name'],
        'tags'       => $user['plan'] === 'pro' ? ['pro'] : [],
    ];
}

$result = $sendboo->subscribers()->sync('email-list-uuid', $rows, unsubscribeMissing: true);
// ['upserted' => 1200, 'unsubscribed' => 7]
```

### Laravel

[](#laravel)

The package is framework-agnostic, but in a Laravel app you can build the rows with an Eloquent collection:

```
$rows = User::where('subscribed', true)->get()
    ->map(fn (User $user) => [
        'email'      => $user->email,
        'first_name' => $user->first_name,
        'tags'       => $user->plan === 'pro' ? ['pro'] : [],
    ])
    ->all();

$sendboo->subscribers()->sync('email-list-uuid', $rows, unsubscribeMissing: true);
```

Scheduled sync (Laravel)
------------------------

[](#scheduled-sync-laravel)

The package is framework-agnostic, but a common setup is a Laravel Artisan command that keeps a Sendboo email list in step with your users. Generate it with `php artisan make:command SyncSendboo`:

```
