PHP SDK for the RafikiSMS Vendor API (X-API-Key) — send SMS, OTP, balance, logs, sender names, delivery reports, webhooks

dev-main 2026-05-18 17:51 UTC

This package is auto-updated.

Last update: 2026-07-18 18:32:04 UTC


README

PHP SDK for the RafikiSMS Vendor API (X-API-Key auth).

Developer docs: https://developers.rafikisms.com/

OpenAPI JSON: https://developers.rafikisms.com/v1/docs/openapi.json

Requirements

  • PHP 8.1+
  • guzzlehttp/guzzle ^7.0

Installation

composer require rafikisms/sdk

Usage

<?php

require 'vendor/autoload.php';

use Rafikisms\Client;

$client = new Client(
    apiKey: getenv('RAFIKISMS_API_KEY'),
);

// Send SMS
$result = $client->sendSms([
    'phone' => '255712345678',
    'message' => 'Hello from RafikiSMS!',
    'sender_id' => 'MYBRAND',
]);

if ($result->success) {
    echo "SMS queued\n";
}

// Balance
$balance = $client->getBalance();
$credits = $balance->data['credit_balance'] ?? 0;

// Resource-oriented usage
$client->sms()->send(['phone' => '255712345678', 'message' => 'Hi']);
$client->otp()->generate(['phone_number' => '255712345678']);

Strict errors

$client = new Client(
    apiKey: getenv('RAFIKISMS_API_KEY'),
    throwOnError: true,
);

try {
    $client->sendSms(['phone' => '255712345678', 'message' => 'Hi']);
} catch (\Rafikisms\Exceptions\ApiException $e) {
    echo $e->result->errorCode;
} catch (\Rafikisms\Exceptions\ValidationException $e) {
    print_r($e->validationErrors);
}

API

All methods return a Rafikisms\Result object with: success, message, errorCode, data, httpStatus, errors.

Method Endpoint
sendSms POST /v1/vendor/send-sms
sendBulkSms POST /v1/vendor/send-bulk-sms
getSmsLogs GET /v1/vendor/sms-logs
getDeliveryReport GET /v1/vendor/delivery-reports
getSenderNames GET /v1/vendor/sender-names
requestSenderName POST /v1/sender-names/request
generateOtp POST /v1/otp/generate
verifyOtp POST /v1/otp/verify
getBalance GET /v1/vendor/balance
updateDeliveryWebhook PUT /v1/vendors/delivery-webhook

License

MIT.