PHPackages                             balfour/php-omnisend - 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. [API Development](/categories/api)
4. /
5. balfour/php-omnisend

ActiveLibrary[API Development](/categories/api)

balfour/php-omnisend
====================

A library for interacting with the Omnisend API

0.0.1-alpha(6y ago)032MITPHP

Since Feb 24Pushed 6y ago6 watchersCompare

[ Source](https://github.com/balfour-group/php-omnisend)[ Packagist](https://packagist.org/packages/balfour/php-omnisend)[ RSS](/packages/balfour-php-omnisend/feed)WikiDiscussions master Synced 2mo ago

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

php-omnisend
============

[](#php-omnisend)

A library for interacting with the Omnisend API.

*This library is in early release and is pending unit tests.*

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Creating a Client](#creating-a-client)
    - [Contacts](#contacts)
        - [Create Contact](#create-contact)
        - [Update Contact](#update-contact)
        - [Retrieve Contact](#retrieve-contact)
        - [List Contacts](#list-contacts)
        - [Subscribe Contact](#subscribe-contact)
        - [Unsubscribe Contact](#unsubscribe-contact)
    - [Events](#events)
        - [List Events](#list-events)
        - [Retrieve Event](#retrieve-event)
        - [Trigger Event](#trigger-event)
    - [Misc Calls](#misc-calls)
- [Laravel Integration](#laravel-integration)
    - [Configuration](#configuration)
    - [Job Handlers](#job-handlers)
        - [CreateContact](#createcontact)
        - [UpdateContact](#updatecontact)
        - [TriggerEvent](#triggerevent)

Installation
------------

[](#installation)

```
composer require balfour/php-omnisend
```

Usage
-----

[](#usage)

Please see  for full API documentation.

### Creating a Client

[](#creating-a-client)

```
use GuzzleHttp\Client;
use Balfour\Omnisend\Omnisend;

$client = new Client();
$omnisend = new Omnisend($client, 'your-api-key');
```

### Contacts

[](#contacts)

#### Create Contact

[](#create-contact)

```
use Carbon\Carbon;
use Balfour\Omnisend\ContactGender;
use Balfour\Omnisend\ContactStatus;

$response = $omnisend->createContact([
    'email' => 'foo@bar.com',
    'firstName' => 'John',
    'lastName' => 'Doe',
    'tags' => [
        'source: Test',
    ],
    'gender' => ContactGender::MALE,
    'phone' => '+27721111111',
    'birthdate' => '1987-03-28',
    'customProperties' => [
        'group' => 'ADMIN',
    ],
]);

// you can also pass an implementation of ContactInterface instead of an array
// of attributes
// eg: assuming $contact is a model which implements ContactInterface
$response = $omnisend->createContact($contact);

// specifying opt-in status & optional params
$response = $omnisend->createContact(
    [
        'email' => 'foo@bar.com',
        'firstName' => 'John',
        'lastName' => 'Doe',
        'tags' => [
            'source: Test',
        ],
        'gender' => ContactGender::MALE,
        'phone' => '+27721111111',
        'birthdate' => '1987-03-28',
        'customProperties' => [
            'group' => 'ADMIN',
        ],
    ],
    ContactStatus::UNSUBSCRIBED,
    Carbon::now(), // status date
    true, // send welcome email
    '127.0.0.1', // opt-in ip address (ipv4 or ipv6)
    Carbon::now(), // opt-in date & time
);
```

#### Update Contact

[](#update-contact)

```
$response = $omnisend->updateContact('5d5be5635c3762bd644e947c', [
    'firstName' => 'John',
    'lastName' => 'Doe',
]);

// you can also pass an implementation of ContactInterface instead of an array
// of attributes
// eg: assuming $contact is a model which implements ContactInterface
$response = $omnisend->updateContact('5d5be5635c3762bd644e947c', $contact);

// update contact using email address as identifier
$response = $omnisend->updateContactByEmail('matthew@masterstart.com', [
    'firstName' => 'John',
    'lastName' => 'Doe',
]);
```

#### Retrieve Contact

[](#retrieve-contact)

```
$response = $omnisend->getContact('5d5be5635c3762bd644e947c');
```

#### List Contacts

[](#list-contacts)

```
use Balfour\Omnisend\ContactStatus;

$response = $omnisend->listContacts();

// list contacts from offset with limit
$response = $omnisend->listContacts(
    50, // starting from offset 50
    100 // limit to 100 results
);

// list contacts by status
$response = $omnisend->listContactsByStatus(ContactStatus::SUBSCRIBED);
```

#### Subscribe Contact

[](#subscribe-contact)

```
$response = $omnisend->subscribeContact('5d5be5635c3762bd644e947c');

// or via email address
$response = $omnisend->subscribeContactByEmail('matthew@masterstart.com');
```

#### Unsubscribe Contact

[](#unsubscribe-contact)

```
$response = $omnisend->unsubscribeContact('5d5be5635c3762bd644e947c');

// or via email address
$response = $omnisend->unsubscribeContactByEmail('matthew@masterstart.com');
```

### Events

[](#events)

#### List Events

[](#list-events)

```
$response = $omnisend->listEvents();
```

#### Retrieve Event

[](#retrieve-event)

``php $response = $omnisend-&gt;getEvent('5d5cf4d98653ed49cd7f1bd2');

// you can also retrieve an event by name // the function will return 'null' if no matching event is found $response = $omnisend-&gt;getEventByName('Payment Complete'); ``

#### Trigger Event

[](#trigger-event)

```
use Balfour\Omnisend\Event;

$omnisend->triggerEvent(
    '5d5cf4d98653ed49cd7f1bd2',
    'matthew@masterstart.com',
    [
        'payment_method' => 'CREDIT CARD',
        'amount' => 'R1200.00',
    ]
);

// you can also pass in an implementation of EventInterface
$paymentCompleteEvent = new Event(
    '5d5cf4d98653ed49cd7f1bd2',
    [
        'payment_method' => 'CREDIT CARD',
        'amount' => 'R1200.00',
    ]
);

$omnisend->triggerEvent($paymentCompleteEvent, 'matthew@masterstart.com');
```

### Misc Calls

[](#misc-calls)

For any other API calls which don't have class functions, you can call the following methods directly on the client.

```
// examples:
$omnisend->get('products');
$omnisend->get('products', ['sort' => 'createdAt']);

$omnisend->post('products', [
    'productId' => '1234',
    'title' => 'My Product',
    // .....
]);

$omnisend->put('products', [
    'productId' => '1234',
    'title' => 'My Product',
    // .....
]);

$omnisend->delete('products/1234');
```

Laravel Integration
-------------------

[](#laravel-integration)

This package comes bundled with a Laravel ServiceProvider &amp; utility classes for easy integration into a Laravel project.

```
use Balfour\Omnisend\Laravel\Event;
use Balfour\Omnisend\Laravel\NamedEvent;
use Balfour\Omnisend\Omnisend;

// resolving client from ioc container
$omnisend = app(Omnisend::class);

// triggering an event
$paymentCompleteEvent = new Event(
    '5d5cf4d98653ed49cd7f1bd2',
    [
        'payment_method' => 'CREDIT CARD',
        'amount' => 'R1200.00',
    ]
);
$paymentCompleteEvent->fire();

// queue an event
// this will use the configured queue (omnisend by default)
$paymentCompleteEvent->enqueue('matthew@masterstart.com');

// the queue name can be overridden
$paymentCompleteEvent->enqueue('matthew@masterstart.com', 'my_queue');

// the laravel integration also comes with a NamedEvent class, where can event
// can be triggered by name instead of id
// the event id is resolved at trigger time from the name, and is cached for subsequent
// triggers
$paymentCompleteEvent = new NamedEvent(
    'Payment Complete',
    [
        'payment_method' => 'CREDIT CARD',
        'amount' => 'R1200.00',
    ]
);
$paymentCompleteEvent->fire();
```

### Configuration

[](#configuration)

The config can be published using `php artisan vendor:publish`.

The following environment variables are supported:

`OMNISEND_ENABLED` - Enable or disable Omnisend integration (defaults to `false`)

`OMNISEND_API_KEY` - Your Omnisend API key

`OMNISEND_QUEUE` - The queue on which jobs will be processed (defaults to `omnisend`)

`OMNISEND_SEND_WELCOME_EMAIL` - If true, a welcome email will be sent to a contact upon creation (defaults to `false`)

`OMNISEND_DEFAULT_CONTACT_STATUS` - The default status when a contact is created. (defaults to `subscribed`)

### Job Handlers

[](#job-handlers)

The following job handlers are included:

#### CreateContact

[](#createcontact)

```
use Balfour\Omnisend\ContactStatus;
use Balfour\Omnisend\Laravel\Jobs\CreateContact;
use Carbon\Carbon;

// eg: assuming $contact is a model which implements ContactInterface
CreateContact::enqueue($contact);

// or
CreateContact::enqueue(
    $contact,
    ContactStatus::SUBSCRIBED,
    true, // send welcome email
    '127.0.0.1', // opt-in ip
    Carbon::now() // opt-in date
);
```

#### UpdateContact

[](#updatecontact)

```
use Balfour\Omnisend\Laravel\Jobs\UpdateContact;

// eg: assuming $contact is a model which implements ContactInterface
UpdateContact::enqueue($contact);
```

#### TriggerEvent

[](#triggerevent)

```
use Balfour\Omnisend\Laravel\Event;
use Balfour\Omnisend\Laravel\Jobs\TriggerEvent;

$paymentCompleteEvent = new Event(
    '5d5cf4d98653ed49cd7f1bd2',
    [
        'payment_method' => 'CREDIT CARD',
        'amount' => 'R1200.00',
    ]
);

TriggerEvent::enqueue($event, 'matthew@masterstart.com');
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

2267d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/054093c4138d9bea138f6226b632f8f7ad0adb516562480f7f77868d481e75f0?d=identicon)[balfourgroup](/maintainers/balfourgroup)

---

Top Contributors

[![matthewgoslett](https://avatars.githubusercontent.com/u/1571743?v=4)](https://github.com/matthewgoslett "matthewgoslett (3 commits)")

### Embed Badge

![Health badge](/badges/balfour-php-omnisend/health.svg)

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

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[ashallendesign/laravel-exchange-rates

A wrapper package for interacting with the exchangeratesapi.io API.

485677.8k](/packages/ashallendesign-laravel-exchange-rates)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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