PHPackages                             mailerlite/mailerlite-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. mailerlite/mailerlite-php

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

mailerlite/mailerlite-php
=========================

MailerLite PHP SDK

v1.0.5(6mo ago)31423.6k—1.4%10[2 issues](https://github.com/mailerlite/mailerlite-php/issues)[1 PRs](https://github.com/mailerlite/mailerlite-php/pulls)3MITPHPPHP ^7.4|^8.0CI passing

Since Sep 30Pushed 6mo ago10 watchersCompare

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

READMEChangelog (6)Dependencies (17)Versions (17)Used By (3)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0820f8a0225840325706de9d31a9b7c93165cc48f1f948115dffb2944c694153/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61696c65726c6974652f6d61696c65726c6974652d7068702e737667)](https://packagist.org/packages/mailerlite/mailerlite-php)[![Tests](https://github.com/mailerlite/mailerlite-php/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mailerlite/mailerlite-php/actions/workflows/test.yml)[![PHPStan](https://github.com/mailerlite/mailerlite-php/actions/workflows/static.yml/badge.svg)](https://github.com/mailerlite/mailerlite-php/actions/workflows/static.yml)[![Total Downloads](https://camo.githubusercontent.com/48be1e2b63ad1d6d70fd51e382f855f59796d8240e70f316e6fd65d900e69adc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61696c65726c6974652f6d61696c65726c6974652d7068702e737667)](https://packagist.org/packages/mailerlite/mailerlite-php)

Table of Contents
=================

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Subscriber API](#subscriber-api)
        - [Create](#create-subscriber)
        - [Read](#read-subscriber)
        - [Update](#update-subscriber)
        - [Delete](#delete-subscriber)
    - [Campaign API](#email-api)
        - [Create](#create-campaign)
        - [Read](#read-campaign)
        - [Update](#update-campaign)
        - [Delete](#delete-campaign)
        - [Schedule](#schedule-campaign)
        - [Cancel](#cancel-campaign)
        - [Subscriber activity](#campaign-subscriber-activity)
    - [Group API](#group)
        - [Create](#group-create)
        - [Update](#group-update)
        - [Read](#group-read)
        - [Delete](#group-delete)
        - [Get subscribers](#group-list-subscribers)
        - [Assign subscriber](#group-assign-subscriber)
        - [Unassign subscriber](#group-unassign-subscriber)
    - [Segment API](#segment)
        - [Update](#segment-update)
        - [Read](#segment-read)
        - [Delete](#segment-delete)
        - [Get subscribers](#segment-list-subscribers)
    - [Field API](#field)
        - [Create](#field-create)
        - [Update](#field-update)
        - [Read](#field-read)
        - [Delete](#field-delete)
    - [Form API](#form)
        - [Update](#form-update)
        - [Read](#form-read)
        - [Delete](#form-delete)
        - [Signups](#form-subscribers)
    - [Automation API](#automation)
        - [Read](#automation-read)
        - [Activity](#automation-activity)
    - [Webhook API](#webhook)
        - [Create](#webhook-create)
        - [Update](#webhook-update)
        - [Read](#webhook-read)
        - [Delete](#webhook-delete)
    - [Campaign language API](#campaign-language-read)
    - [Timezone API](#timezone-read)
    - [Batch API](#batch-send)
- [Optional PSR transport (no BC break)](#optional-psr-transport-no-bc-break)
- [E-commerce (Products / Orders / Customers)](#e-commerce)
- [Testing](#testing)
- [License](#license)

Installation
============

[](#installation)

Requirements
------------

[](#requirements)

- PHP 7.4
- An API Key from MailerLite
- PSR-7 and PSR-18 based HTTP adapter

Setup
-----

[](#setup)

```
composer require mailerlite/mailerlite-php
```

If you get an error saying “Could not find resource using any discovery strategy.” it means that all the discovery strategies have failed. Most likely, your project is missing the message factories and/or a PRS-7 implementation. To resolve this you may run

```
$ composer require php-http/curl-client guzzlehttp/psr7 php-http/message
```

Usage
=====

[](#usage)

Subscriber
----------

[](#subscriber)

More information on request parameters:

### Create

[](#create)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$data = [
    'email' => 'subscriber@example.com',
];

$response = $mailerLite->subscribers->create($data);
```

### Read

[](#read)

Single record

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$subscriberId = '123';

$response = $mailerLite->subscribers->find($subscriberId);
```

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->subscribers->get();
```

### Update

[](#update)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$subscriberId = '123',

$data = [
    'fields' => [
        'name' => 'Example',
    ],
];

$response = $mailerLite->subscribers->update($subscriberId, $data);
```

### Delete

[](#delete)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$subscriberId = '123';

$response = $mailerLite->subscribers->delete($subscriberId);
```

Campaign
--------

[](#campaign)

More information on request parameters:

### Create

[](#create-1)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$data = [
    'type' => 'regular',
    'name' => 'My new campaign',
    'language_id' => 10,
    'emails' => [
        [
            'subject' => 'My new email',
            'from_name' => 'me',
            'from' => 'me@example.com',
            'content' => 'Hello World!',
        ]
    ],
    'filter' => [],
];

$response = $mailerLite->campaigns->create($data);
```

### Read

[](#read-1)

Single record

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$campaignId = '123';

$response = $mailerLite->campaigns->find($campaignId);
```

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$data = [
    'filter' => ['status' => 'sent'],
];

$response = $mailerLite->campaigns->get($data);
```

### Update

[](#update-1)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$campaignId = '123';

$data = [
    'name' => 'Changed campaign name',
    'emails' => [
        [
            'subject' => 'Changed email subject',
            'from_name' => 'Changed from name',
            'from' => 'changed@example.com',
        ]
    ],
];

$response = $mailerLite->campaigns->update($campaignId, $data);
```

### Delete

[](#delete-1)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$campaignId = '123';

$response = $mailerLite->campaigns->delete($campaignId);
```

### Schedule

[](#schedule)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$campaignId = '123';

$data = [
    'delivery' => 'instant',
];

$response = $mailerLite->campaigns->schedule($campaignId, $data);
```

### Cancel

[](#cancel)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$campaignId = '123';

$response = $mailerLite->campaigns->cancel($campaignId);
```

### Subscriber activity of sent campaign

[](#subscriber-activity-of-sent-campaign)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$campaignId = '123';
$data = [
    'type' => 'opened',
];

$response = $mailerLite->campaigns->getSubscriberActivity($campaignId, $data);
```

Group API
---------

[](#group-api)

More information on request parameters:

### Create

[](#create-2)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$data = [
    "name" => "New group",
];

$response = $mailerLite->groups->create($data);
```

### Read

[](#read-2)

Single record

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$groupId = '123';

$response = $mailerLite->groups->find($groupId);
```

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->groups->get();
```

### Update

[](#update-2)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$groupId = '123';
$data = [
    "name" => "Updated name",
];

$response = $mailerLite->groups->update($groupId, $data);
```

### Delete

[](#delete-2)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$groupId = '123';

$response = $mailerLite->groups->delete($groupId);
```

### Get subscribers who belong to a group

[](#get-subscribers-who-belong-to-a-group)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$groupId = '123';

$response = $mailerLite->groups->getSubscribers($groupId);
```

### Assign subscriber to a group

[](#assign-subscriber-to-a-group)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$groupId = '123';
$subscriberId = '456';

$response = $mailerLite->groups->assignSubscriber($groupId, $subscriberId);
```

### unassign subscriber from a group

[](#unassign-subscriber-from-a-group)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$groupId = '123';
$subscriberId = '456';

$response = $mailerLite->groups->unAssignSubscriber($groupId, $subscriberId);
```

Segment API
-----------

[](#segment-api)

More information on request parameters:

### Read

[](#read-3)

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->segments->get();
```

### Update

[](#update-3)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$segmentId = '123';
$data = [
    "name" => "Updated name",
];

$response = $mailerLite->segments->update($segmentId, $data);
```

### Delete

[](#delete-3)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$segmentId = '123';

$response = $mailerLite->segments->delete($segmentId);
```

### Get subscribers who belong to a segment

[](#get-subscribers-who-belong-to-a-segment)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$segmentId = '123';

$response = $mailerLite->segments->getSubscribers($segmentId);
```

Field API
---------

[](#field-api)

More information on request parameters:

### Create

[](#create-3)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$data = [
    "name" => "New field",
    "type" => "text",
];

$response = $mailerLite->fields->create($data);
```

### Read

[](#read-4)

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->fields->get();
```

### Update

[](#update-4)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$fieldId = '123';
$data = [
    "name" => "Updated name",
];

$response = $mailerLite->fields->update($fieldId, $data);
```

### Delete

[](#delete-4)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$fieldId = '123';

$response = $mailerLite->fields->delete($fieldId);
```

Form API
--------

[](#form-api)

More information on request parameters:

### Read

[](#read-5)

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->forms->get('popup', []);
```

Single

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$formId = '123';

$response = $mailerLite->forms->find($formId);
```

### Update

[](#update-5)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$formId = '123';
$data = [
    "name" => "Updated name",
];

$response = $mailerLite->forms->update($formId, $data);
```

### Delete

[](#delete-5)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$formId = '123';

$response = $mailerLite->forms->delete($formId);
```

### Signed up subscribers

[](#signed-up-subscribers)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$formId = '123';

$response = $mailerLite->forms->getSignups($formId);
```

Automation API
--------------

[](#automation-api)

More information on request parameters:

### Read

[](#read-6)

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->automations->get([]);
```

Single

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$automationId = '123';

$response = $mailerLite->automations->find($automationId);
```

### Activity

[](#activity)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$automationId = '123';
$data = [
    'filter' => [
        'status' => 'active',
    ],
];

$response = $mailerLite->automations->activity($automationId, $data);
```

Webhook API
-----------

[](#webhook-api)

More information on request parameters:

### Create

[](#create-4)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$data = [
    "name" => "Name",
    "events" => ["subscriber.created"],
    "url": "https://www.cartwright.info/eligendi-soluta-corporis-in-quod-ullam",
];

$response = $mailerLite->webhooks->create($data);
```

### Read

[](#read-7)

All records

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->webhooks->get([]);
```

Single

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$webhookId = '123';

$response = $mailerLite->webhooks->find($webhookId);
```

### Update

[](#update-6)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$webhookId = '123';
$data = [
    "name" => "Updated name",
];

$response = $mailerLite->webhooks->update($webhookId, $data);
```

### Delete

[](#delete-6)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$webhookId = '123';

$response = $mailerLite->webhooks->delete($webhookId);
```

Campaign language API
---------------------

[](#campaign-language-api)

More information about request parameters on

### Read

[](#read-8)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->campaignLanguages->get();
```

Timezone API
------------

[](#timezone-api)

More information about request parameters on

### Read

[](#read-9)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$response = $mailerLite->timezones->get();
```

Batch API
---------

[](#batch-api)

More information about request parameters on

E-commerce (Products / Orders / Customers)
------------------------------------------

[](#e-commerce-products--orders--customers)

E-commerce endpoints follow:

```
/api/ecommerce/shops/{shopId}/...
```

`shopId` is provided per call (there is no separate `/shops` API).

**Products**

```
$res = $mailerLite->ecommerceProducts->create('YOUR_SHOP_ID', [
    'title'    => 'Red T-shirt',
    'price'    => 19.99,
    'currency' => 'USD',
]);

$res = $mailerLite->ecommerceProducts->find('YOUR_SHOP_ID', 'PRODUCT_ID');

$res = $mailerLite->ecommerceProducts->update('YOUR_SHOP_ID', 'PRODUCT_ID', [
    'title' => 'New title',
]);
```

**Orders**

```
$res = $mailerLite->ecommerceOrders->create('YOUR_SHOP_ID', [
   'order_id' => 'ORD-1001',
]);

$res = $mailerLite->ecommerceOrders->find('YOUR_SHOP_ID', 'ORD-1001');

$res = $mailerLite->ecommerceOrders->update('YOUR_SHOP_ID', 'ORD-1001', [
    'status' => 'paid',
]);
```

**Customers**

```
$res = $mailerLite->ecommerceCustomers->get('YOUR_SHOP_ID', ['limit' => 50]);
$res = $mailerLite->ecommerceCustomers->create('YOUR_SHOP_ID', ['email' => 'user@example.com']);
$res = $mailerLite->ecommerceCustomers->find('YOUR_SHOP_ID', 'CUSTOMER_ID');
```

Optional PSR transport (no BC break)
------------------------------------

[](#optional-psr-transport-no-bc-break)

```
use MailerLite\MailerLite;
use MailerLite\Http\Adapters\Psr17FactoryAggregate;
use Nyholm\Psr7\Factory\Psr17Factory;
use GuzzleHttp\Client as GuzzleHttpClient;
$ml = new MailerLite(['api_key' => 'YOUR_API_KEY']);

$psr17 = new Psr17Factory();
$factories = new Psr17FactoryAggregate($psr17, $psr17);

$httpClient = new GuzzleHttpClient();

$ml->enablePsrTransport($httpClient, $factories, 'YOUR_API_KEY', 'https://connect.mailerlite.com');

$ml->subscribers->create(['email' => 'subscriber@example.com']);
```

### Send

[](#send)

```
use MailerLite\MailerLite;

$mailerLite = new MailerLite(['api_key' => 'key']);

$data = [
    'requests' => [
        [
            'method' => 'post',
            'path' => 'api/subscribers',
            'body' => [
                'email' => 'new_subscriber@mail.com'
            ]
        ]
    ]
];
$response = $mailerLite->batches->send($data);
```

Testing
=======

[](#testing)

```
composer test
```

Support and Feedback
====================

[](#support-and-feedback)

In case you find any bugs, submit an issue directly here in GitHub.

You are welcome to create SDK for any other programming language.

If you have any troubles using our API or SDK free to contact our support by email

License
=======

[](#license)

[The MIT License (MIT)](LICENSE.md)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance67

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 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 ~204 days

Recently: every ~223 days

Total

6

Last Release

187d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f40e782a8e6ee52ee612002cb2d97a56c298f5b166e249adea21bcd731fdd27?d=identicon)[mailerlite](/maintainers/mailerlite)

---

Top Contributors

[![npetrunova](https://avatars.githubusercontent.com/u/11510615?v=4)](https://github.com/npetrunova "npetrunova (17 commits)")[![rekerta](https://avatars.githubusercontent.com/u/39701684?v=4)](https://github.com/rekerta "rekerta (14 commits)")[![johnkelesidis](https://avatars.githubusercontent.com/u/72185528?v=4)](https://github.com/johnkelesidis "johnkelesidis (5 commits)")[![gaurang404](https://avatars.githubusercontent.com/u/132255421?v=4)](https://github.com/gaurang404 "gaurang404 (5 commits)")[![thenabeel](https://avatars.githubusercontent.com/u/3117493?v=4)](https://github.com/thenabeel "thenabeel (3 commits)")[![Michalus211](https://avatars.githubusercontent.com/u/150010395?v=4)](https://github.com/Michalus211 "Michalus211 (3 commits)")[![nklmilojevic](https://avatars.githubusercontent.com/u/9573356?v=4)](https://github.com/nklmilojevic "nklmilojevic (3 commits)")[![shuvroroy](https://avatars.githubusercontent.com/u/21066418?v=4)](https://github.com/shuvroroy "shuvroroy (3 commits)")[![dinomh](https://avatars.githubusercontent.com/u/25065792?v=4)](https://github.com/dinomh "dinomh (3 commits)")[![gsteel](https://avatars.githubusercontent.com/u/2803720?v=4)](https://github.com/gsteel "gsteel (2 commits)")[![pushkidman](https://avatars.githubusercontent.com/u/21977886?v=4)](https://github.com/pushkidman "pushkidman (1 commits)")[![mlasek1991](https://avatars.githubusercontent.com/u/135223609?v=4)](https://github.com/mlasek1991 "mlasek1991 (1 commits)")[![Stasky745](https://avatars.githubusercontent.com/u/72012651?v=4)](https://github.com/Stasky745 "Stasky745 (1 commits)")[![ishifoev](https://avatars.githubusercontent.com/u/34019391?v=4)](https://github.com/ishifoev "ishifoev (1 commits)")

---

Tags

sdksdkemailmarketingmailerlite

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[mailerlite/mailerlite-api-v2-php-sdk

MailerLite API v2 PHP SDK

801.7M15](/packages/mailerlite-mailerlite-api-v2-php-sdk)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

963.1M35](/packages/getbrevo-brevo-php)[railsware/mailtrap-php

The Mailtrap SDK provides methods for all API functions.

56770.5k](/packages/railsware-mailtrap-php)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15224.3M65](/packages/opensearch-project-opensearch-php)

PHPackages © 2026

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