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

ActiveLibrary[API Development](/categories/api)

statum/statum-php-sdk
=====================

Official PHP SDK for Statum APIs (SMS, Airtime, Account)

v1.0.5(1mo ago)021MITPHPPHP ^8.1CI passing

Since Jan 18Pushed 1mo agoCompare

[ Source](https://github.com/StatumKE/statum-php-sdk)[ Packagist](https://packagist.org/packages/statum/statum-php-sdk)[ RSS](/packages/statum-statum-php-sdk/feed)WikiDiscussions main Synced 1w ago

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

Statum PHP SDK (SMS, Airtime, &amp; Accounts)
=============================================

[](#statum-php-sdk-sms-airtime--accounts)

[![PHP Version](https://camo.githubusercontent.com/acffb6ae1962992d26e4466782832787e79504a6250f80d732c4283458b9f497/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e737667)](https://packagist.org/packages/statum/statum-php-sdk)[![Latest Stable Version](https://camo.githubusercontent.com/b6a7d0767bd23cff30e139d75a6f95a5db35082ee77007e1bfd1aa500c26f1b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746174756d2f73746174756d2d7068702d73646b2e737667)](https://packagist.org/packages/statum/statum-php-sdk)[![License](https://camo.githubusercontent.com/329dc3d585d7063a4fcc59ee105dd2ea6239701f368b7dfbaaca3d24ebe5bb51/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f53746174756d4b452f73746174756d2d7068702d73646b2e737667)](https://github.com/StatumKE/statum-php-sdk/blob/master/LICENSE)

Official PHP SDK for Statum APIs. Built for secure, production-grade enterprise usage with strict typing, immutable DTOs, and framework-agnostic Guzzle HTTP integrations. Easily send SMS alerts, automate airtime disbursements, and query real-time account balances.

---

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

[](#table-of-contents)

- [Features](#features)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Quick Start in 2 Minutes](#quick-start-in-2-minutes)
    - [1. Plain PHP Setup](#1-plain-php-setup)
    - [2. Laravel Setup](#2-laravel-setup)
- [Core Integration Examples](#core-integration-examples)
    - [Account Details](#account-details)
    - [Sending SMS](#sending-sms)
    - [Disbursing Airtime](#disbursing-airtime)
- [Error &amp; Exception Handling](#error--exception-handling)
- [API JSON Payload Specifications](#api-json-payload-specifications)
- [Integration Guidelines &amp; Gotchas](#integration-guidelines--gotchas)
- [Running Tests](#running-tests)
- [License](#license)

---

Features
--------

[](#features)

- **Type-Safe Constructors**: Parameter validation happens locally inside the SDK before outgoing HTTP calls.
- **Service-Oriented Design**: Clean division between SMS, Airtime, and Account APIs.
- **Framework Agnostic**: Works out of the box in plain scripts, Symfony, or Laravel.
- **Extensive Exception Handling**: Maps specific HTTP status codes (e.g. 401, 402, 422) to concrete PHP exception classes.
- **Strict Typing**: Full compatibility with PHP 8.1+ strict mode.

---

Getting Started
---------------

[](#getting-started)

1. **Sign up for a Statum account**: [app.statum.co.ke](https://app.statum.co.ke)
2. **Get your API credentials**: Retrieve your Consumer Key and Consumer Secret from the [Statum Dashboard](https://app.statum.co.ke/user).
3. **Read the full API documentation**: [docs.statum.co.ke](https://docs.statum.co.ke)
4. **Install the SDK**: Follow the [Installation](#installation) guidelines below.

---

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

[](#installation)

Install the package via Composer:

```
composer require statum/statum-php-sdk
```

---

Quick Start in 2 Minutes
------------------------

[](#quick-start-in-2-minutes)

Ensure your credentials are saved in your `.env` or system environment:

```
STATUM_CONSUMER_KEY=your-consumer-key
STATUM_CONSUMER_SECRET=your-consumer-secret
```

### 1. Plain PHP Setup

[](#1-plain-php-setup)

```
use Statum\Sdk\StatumClient;

$client = StatumClient::create(
    consumerKey: $_ENV['STATUM_CONSUMER_KEY'],
    consumerSecret: $_ENV['STATUM_CONSUMER_SECRET']
);
```

### 2. Laravel Setup

[](#2-laravel-setup)

The SDK supports package auto-discovery in Laravel. To configure it, publish the configuration file:

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

This will create a `config/statum.php` file. You can configure your credentials via your `.env` file:

```
STATUM_CONSUMER_KEY=your-consumer-key
STATUM_CONSUMER_SECRET=your-consumer-secret
STATUM_BASE_URL=https://api.statum.co.ke/api/v2
STATUM_TIMEOUT=30.0
```

Now type-hint `StatumClient` in any controller or job to inject the initialized client:

```
use Statum\Sdk\StatumClient;

class SmsController extends Controller
{
    public function __construct(private readonly StatumClient $client) {}

    public function send() {
        // Ready to make type-safe calls!
    }
}
```

---

Core Integration Examples
-------------------------

[](#core-integration-examples)

### Account Details

[](#account-details)

Fetch organization profile, available balances, and service configuration:

```
$response = $client->account()->getAccountDetails();

echo "Status Code: " . $response->statusCode . "\n";
echo "Organization: " . $response->organization->name . "\n";
echo "Available Balance: KES " . $response->organization->details->availableBalance . "\n";

// List registered services and account codes
foreach ($response->organization->accounts as $account) {
    echo "Service: " . $account->serviceName . " | Code: " . $account->account . "\n";
}
```

### Sending SMS

[](#sending-sms)

Send transactional or promotional SMS alerts to a recipient phone number:

```
$response = $client->sms()->sendSms(
    phoneNumber: '254721553678', // Recipient phone number in international format
    senderId: 'STATUM',     // Your approved Sender ID
    message: 'Hello! This is a secure notification from Statum SDK.'
);

echo "Status Code: " . $response->statusCode . "\n";
echo "Description: " . $response->description . "\n";
echo "Request ID: " . $response->requestId . "\n";
```

### Disbursing Airtime

[](#disbursing-airtime)

Disburse airtime rewards or incentives (supports amounts from KES 5 to KES 10,000):

```
$response = $client->airtime()->sendAirtime(
    phoneNumber: '254721553678',
    amount: '100' // Amount must be passed as a string representation
);

echo "Status Code: " . $response->statusCode . "\n";
echo "Description: " . $response->description . "\n";
echo "Request ID: " . $response->requestId . "\n";
```

---

Error &amp; Exception Handling
------------------------------

[](#error--exception-handling)

The SDK maps HTTP responses to concrete exception classes that inherit from `Statum\Sdk\Exceptions\ApiException`.

```
use Statum\Sdk\Exceptions\AuthenticationException;
use Statum\Sdk\Exceptions\ValidationException;
use Statum\Sdk\Exceptions\NetworkException;
use Statum\Sdk\Exceptions\ApiException;

try {
    $response = $client->sms()->sendSms('2547XXXXXXXX', 'SENDERID', 'Message');
} catch (AuthenticationException $e) {
    // Credentials failed validation (HTTP 401)
    echo "Auth Failure: Check Consumer Key and Secret.";
} catch (ValidationException $e) {
    // API-side validation parameters failed (HTTP 422)
    echo "Request ID: " . $e->getRequestId() . "\n";
    foreach ($e->getValidationErrors() as $field => $errors) {
        echo "Field '$field' errors: " . implode(', ', $errors) . "\n";
    }
} catch (NetworkException $e) {
    // DNS, timeouts, or connection failures
    echo "Connection error: " . $e->getMessage();
} catch (ApiException $e) {
    // General API errors (e.g. 402 Insufficient Funds, 500 Server Error)
    echo "HTTP Status Code: " . $e->getCode() . "\n";
    echo "Error Body: " . $e->getResponseBody() . "\n";
}
```

---

API JSON Payload Specifications
-------------------------------

[](#api-json-payload-specifications)

Here are the wire-level JSON schemas transmitted and returned by the APIs under the hood:

### 1. SMS API

[](#1-sms-api)

- **Endpoint**: `POST /sms`
- **Headers**: `Authorization: Basic `

**JSON Request**```
{
  "phone_number": "254721553678",
  "sender_id": "STATUM",
  "message": "Hello from Statum SDK!"
}
```

**JSON Response (Success - 200)**```
{
  "status_code": 200,
  "description": "Operation successful.",
  "request_id": "d173a8b3-0f3a-463f-8a03-29826b9a2d78"
}
```

---

### 2. Airtime API

[](#2-airtime-api)

- **Endpoint**: `POST /airtime`

**JSON Request**```
{
  "phone_number": "254721553678",
  "amount": "100"
}
```

**JSON Response (Success - 200)**```
{
  "status_code": 200,
  "description": "Operation successful.",
  "request_id": "6e0213d5-6df9-47bf-ba2d-9b9470d96854"
}
```

---

### 3. Account Details API

[](#3-account-details-api)

- **Endpoint**: `GET /account-details`

**JSON Response (Success - 200)**```
{
  "status_code": 200,
  "description": "Operation successful.",
  "request_id": "5a45bc7b-bf99-49ae-b089-9daf5f4adbb0",
  "organization": {
    "name": "Statum Test",
    "details": {
      "available_balance": 695.15,
      "location": "Nairobi - Westlands",
      "website": "www.statum.co.ke",
      "office_email": "admin@statum.co.ke",
      "office_mobile": "+254722199199",
      "mpesa_account_top_up_code": "B9E573"
    },
    "accounts": [
      { "account": "Statum", "service_name": "sms" },
      { "account": "CONNECT", "service_name": "sms" }
    ]
  }
}
```

---

Integration Guidelines &amp; Gotchas
------------------------------------

[](#integration-guidelines--gotchas)

1. **Sender ID Approval**: SMS requests will throw an HTTP 422 `ValidationException` if the `senderId` is not registered and approved under your Statum account profile.
2. **Phone Number Formatting**: Ensure phone numbers are passed in the international format (with or without `+` prefix), e.g. `254721553678` or `+254721553678`.
3. **Airtime Limits**: Airtime amounts must be passed as **strings** (e.g. `'100'`) and must fall strictly within the KES 5 to KES 10,000 range per transaction.

---

Running Tests
-------------

[](#running-tests)

Ensure PHPUnit is configured and run:

```
composer install
composer test
```

---

License
-------

[](#license)

This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance94

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Every ~34 days

Recently: every ~43 days

Total

6

Last Release

31d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.2

v1.0.2PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/931a6f10226e9d76e5c3c90b76f680f4b1cd1f648e5e2f8c464c4fdf205f3f6b?d=identicon)[sirBobz](/maintainers/sirBobz)

---

Top Contributors

[![sirBobz](https://avatars.githubusercontent.com/u/15842737?v=4)](https://github.com/sirBobz "sirBobz (21 commits)")

---

Tags

smspaymentsmpesakenyaairtimestatum

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k51](/packages/neuron-core-neuron-ai)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)[plivo/plivo-php

A PHP SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML

1113.2M19](/packages/plivo-plivo-php)[plivo/php-sdk

A PHP SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML

1112.1M6](/packages/plivo-php-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2482.9k](/packages/filescom-files-php-sdk)

PHPackages © 2026

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