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

ActiveLibrary

sendafrica/php-sdk
==================

Official PHP SDK for the SendAfrica SMS API — send SMS, check balance, and manage your account.

v2.0.0(1mo ago)10MITPHPPHP &gt;=7.4

Since Jul 17Pushed 1mo agoCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

SendAfrica SDK
==============

[](#sendafrica-sdk)

[![PHP](https://camo.githubusercontent.com/7b544791ebb173103e3c835aa711260f8c002114199321e60b6a09f9c6487423/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73656e646166726963612f73656e64616672696361)](https://packagist.org/packages/sendafrica/sendafrica)[![Version](https://camo.githubusercontent.com/650e4a5edc27b9954ffdf0da453d0794db6237caeb02d5534a25047e2c2d0f65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656e646166726963612f73656e64616672696361)](https://packagist.org/packages/sendafrica/sendafrica)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Official PHP client for the [SendAfrica](https://sendafrica.online) SMS Infrastructure-as-a-Service API. Designed to feel like Stripe's PHP library: simple for a first integration, enough control for production use.

---

What You Get
------------

[](#what-you-get)

- **Fail-fast validation** -- phone numbers are normalized to E.164 and validated locally *before* any network call. Bad input never hits the wire.
- **Automatic retries** -- exponential backoff on 429/5xx/connection errors, with `Retry-After` header respect. No retry loops in your code.
- **Phone number normalization** -- pass `0712345678`, `+255 712 345 678`, or `255712345678` and it all works. The SDK handles the conversion.
- **SMS cost estimation** -- `$client->sms->analyze()` tells you encoding (GSM-7 vs UCS-2), segment count, and credit cost with zero network calls.
- **Full auth system** -- `$client->auth` gives you registration OTP, login OTP, password reset, phone verification, transaction OTP, and custom OTP flows with built-in hashing and expiry verification.
- **Stripe-like error hierarchy** -- every error inherits from `SendAfricaException`. Catch the base class or get specific with `InsufficientCreditsException`, `RateLimitException`, etc.
- **Bulk SMS with partial failure handling** -- `sendMany()` sends sequentially, collects per-message failures, and never aborts the batch on a single bad number.
- **Webhook signature verification** -- HMAC-SHA256 verification for incoming webhook payloads.
- **CLI** -- quick balance checks and SMS sending from the terminal without writing any code.

---

Install
-------

[](#install)

```
composer require sendafrica/sendafrica
```

**Requirements:** PHP 7.4+, ext-curl, ext-json

---

Quickstart
----------

[](#quickstart)

```
