Sendexa LogoDocs
SDK
v0.1.0

PHP SDK

The official PHP SDK for Sendexa. One package, one client, every API — SMS, OTP, WhatsApp, Email, Voice, and Webhook verification.

Zero Dependencies

Uses only PHP built-ins — ext-curl and ext-json. No Composer bloat.

Framework Agnostic

Works in Laravel, Symfony, WordPress, plain PHP, and any SAPI.

Strictly Typed

Full declare(strict_types=1), readonly properties, and PHPDoc types throughout.

PHP 8.1+

Leverages named arguments, readonly properties, and intersection types.

Installation
Bash
composer require sendexa/sdk
Initialise the Client

Create one client instance per application and reuse it — the client is stateless and safe to share across requests.

PHP
<?php
use Sendexa\Sendexa;
$client = new Sendexa(
apiKey: $_ENV['SENDEXA_API_KEY'],
apiSecret: $_ENV['SENDEXA_API_SECRET'],
);
API Examples

Send single and bulk SMS messages with delivery tracking.

PHP
// Send a single SMS
$response = $client->sms->send('0244123456', 'MyBrand', 'Your order #1234 has been confirmed!');
echo $response['data']['messageId'] . PHP_EOL;
// Send bulk SMS
$client->sms->sendBulk(
from: 'MyBrand',
messages: [
['to' => '0244123456', 'message' => 'Hi Alice!'],
['to' => '0555987654'], // uses shared message
],
message: 'Hello from MyBrand!',
);
// Check delivery status
$status = $client->sms->getStatus($response['data']['messageId']);
echo $status['data']['status']; // "delivered"
// Resend a failed message
$client->sms->resend($response['data']['messageId']);
Error Handling

All API errors throw a SendexaException with structured properties for easy branching.

PHP
use Sendexa\Sendexa;
use Sendexa\SendexaException;
try {
$client->sms->send('0244123456', 'MyBrand', 'Hi!');
} catch (SendexaException $e) {
echo $e->status; // HTTP status e.g. 403
echo $e->code; // API code e.g. "SENDER_ID_NOT_APPROVED"
echo $e->getMessage();// Human text e.g. "Sender ID not approved"
echo $e->requestId; // Trace ID for Sendexa support
}
PropertyTypeDescription
$e->statusintHTTP status code (400, 401, 403, 429…)
$e->codestringMachine-readable error code from the API
$e->getMessage()stringHuman-readable description of the error
$e->requestIdstring|nullSendexa trace ID — include when contacting support
$e->rawmixedThe full raw error payload from the API