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

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

nashra/sdk
==========

Official PHP SDK for the Nashra API

v1.0.0(2mo ago)081—0%MITPHPPHP ^8.2CI passing

Since Mar 2Pushed 2mo agoCompare

[ Source](https://github.com/nashra-tech/nashra-sdk-laravel)[ Packagist](https://packagist.org/packages/nashra/sdk)[ RSS](/packages/nashra-sdk/feed)WikiDiscussions main Synced 1mo ago

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

Nashra PHP SDK
==============

[](#nashra-php-sdk)

Official PHP SDK for the [Nashra](https://nashra.ai) API.

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

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

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

[](#installation)

```
composer require nashra/sdk
```

The package auto-discovers itself. No manual provider registration needed.

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=nashra-config
```

Add your API key to `.env`:

```
NASHRA_API_KEY=your-api-key
NASHRA_BASE_URL=https://app.nashra.ai/api/v1  # optional
NASHRA_TIMEOUT=30                               # optional, seconds
NASHRA_MAX_RETRIES=3                            # optional
```

Usage
-----

[](#usage)

### Via Facade

[](#via-facade)

```
use Nashra\Sdk\Facades\Nashra;

// Subscribers
$subscribers = Nashra::subscribers()->list(['search' => 'john']);
$subscriber = Nashra::subscribers()->create(['email' => 'john@example.com', 'first_name' => 'John']);
$subscriber = Nashra::subscribers()->find('uuid');
$subscriber = Nashra::subscribers()->update('uuid', ['first_name' => 'Jane']);
Nashra::subscribers()->delete('uuid');

// Tags
$tags = Nashra::tags()->list();
$tag = Nashra::tags()->create(['name' => 'VIP', 'color' => '#FF0000']);
$tag = Nashra::tags()->update('uuid', ['name' => 'Premium']);
Nashra::tags()->delete('uuid');

// Custom Fields
$fields = Nashra::fields()->list();
$field = Nashra::fields()->create([
    'field_name' => 'Company',
    'data_name' => 'company',
    'type' => 'text',
]);
$field = Nashra::fields()->update('uuid', ['is_required' => true]);
Nashra::fields()->delete('uuid');

// Segments (read-only)
$segments = Nashra::segments()->list();
$segment = Nashra::segments()->find('uuid');
```

### Via Dependency Injection

[](#via-dependency-injection)

```
use Nashra\Sdk\Nashra;

class SubscriberController
{
    public function __construct(private Nashra $nashra) {}

    public function index()
    {
        return $this->nashra->subscribers()->list();
    }
}
```

### Direct Instantiation

[](#direct-instantiation)

Works outside of Laravel too:

```
$nashra = new \Nashra\Sdk\Nashra('your-api-key');
$nashra->subscribers()->list();
```

Pagination
----------

[](#pagination)

Paginated endpoints return a `PaginatedResponse` that implements `IteratorAggregate`:

```
// Auto-paginate through all pages
foreach (Nashra::subscribers()->list() as $subscriber) {
    echo $subscriber->email;
}

// Work with a single page
$page = Nashra::subscribers()->list(['page' => 2, 'per_page' => 50]);
$page->items();       // Subscriber[]
$page->total();       // int
$page->currentPage(); // int
$page->lastPage();    // int
$page->hasMorePages(); // bool
```

Error Handling
--------------

[](#error-handling)

The SDK throws typed exceptions for different error scenarios:

```
use Nashra\Sdk\Exceptions\AuthenticationException;
use Nashra\Sdk\Exceptions\AuthorizationException;
use Nashra\Sdk\Exceptions\NotFoundException;
use Nashra\Sdk\Exceptions\ValidationException;
use Nashra\Sdk\Exceptions\RateLimitException;
use Nashra\Sdk\Exceptions\ApiException;

try {
    Nashra::subscribers()->create(['email' => 'invalid']);
} catch (ValidationException $e) {
    $e->errors(); // ['email' => ['The email must be a valid email address.']]
} catch (AuthenticationException $e) {
    // Invalid API key (401)
} catch (AuthorizationException $e) {
    // No newsletter configured (403)
} catch (NotFoundException $e) {
    // Resource not found (404)
} catch (RateLimitException $e) {
    $e->retryAfter(); // seconds until retry
} catch (ApiException $e) {
    // Server error (5xx)
}
```

Data Objects
------------

[](#data-objects)

All API responses are mapped to readonly data objects:

- `Subscriber` - email, firstName, lastName, status, tags, extraAttributes, notes
- `Tag` - name, color
- `CustomField` - fieldName, dataName, type, isRequired
- `Segment` - name, subscribersCount, storedConditions

Testing
-------

[](#testing)

Since the SDK uses Laravel's HTTP client under the hood, you can use `Http::fake()` to mock API responses in your tests:

```
use Illuminate\Support\Facades\Http;
use Nashra\Sdk\Facades\Nashra;

Http::fake([
    '*/subscribers' => Http::response([
        'data' => [
            [
                'uuid' => 'test-uuid',
                'email' => 'john@example.com',
                'first_name' => 'John',
                'last_name' => 'Doe',
                'status' => 'subscribed',
                'tags' => [],
            ],
        ],
        'meta' => [
            'current_page' => 1,
            'last_page' => 1,
            'total' => 1,
            'per_page' => 15,
        ],
    ]),
]);

$subscribers = Nashra::subscribers()->list();
```

You can also mock specific scenarios like validation errors:

```
Http::fake([
    '*/subscribers' => Http::response([
        'error' => [
            'message' => 'Validation failed',
            'details' => ['email' => ['The email must be a valid email address.']],
        ],
    ], 422),
]);
```

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance85

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

77d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12780866?v=4)[Saleem Hadad سليم حداد](/maintainers/saleem-hadad)[@saleem-hadad](https://github.com/saleem-hadad)

---

Top Contributors

[![saleem-hadad](https://avatars.githubusercontent.com/u/12780866?v=4)](https://github.com/saleem-hadad "saleem-hadad (5 commits)")

---

Tags

apisdkemailnewsletternashra

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[hocza/sendy

Sendy API implementation for Laravel

71195.5k](/packages/hocza-sendy)[ecomailcz/ecomail

Ecomail.cz API Wrapper

17383.8k4](/packages/ecomailcz-ecomail)[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

14109.2k](/packages/hafael-azure-mailer-driver)

PHPackages © 2026

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