zendsms / laravel
Official Laravel package for the Zend SMS API — send SMS, OTP, check balance & DLR.
v1.0.0
2026-09-09 23:37 UTC
Requires
- php: ^8.1
- illuminate/http: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Official Laravel package for the Zend SMS API — send SMS, OTP, check balance, and fetch delivery reports.
Requires: PHP 8.1+ · Laravel 10 / 11 / 12
Install
composer require zendsms/laravel
Publish the config (optional):
php artisan vendor:publish --tag=zendsms-config
Configure
Add your portal API key to .env:
ZENDSMS_API_KEY=sk_your_api_key ZENDSMS_SENDER_ID=YOUR_CLI # ZENDSMS_BASE_URL=https://api.zendsms.com # ZENDSMS_TIMEOUT=30
Create keys under Developer API in the customer portal.
Usage
Facade
use ZendSms\Laravel\Facades\ZendSms; // Send SMS $res = ZendSms::sendSms('01712345678', 'YOUR_CLI', 'Hello from Laravel', 'ORDER-10592'); // $res['data']['message_id'], $res['data']['status'] === 'QUEUED' // OTP $sent = ZendSms::sendOtp('01712345678', 'YOUR_CLI', expiry: 300); ZendSms::verifyOtp($sent['data']['otp_id'], '482913'); // Balance & DLR ZendSms::balance(); ZendSms::dlr($messageId);
Dependency injection
use ZendSms\Laravel\Client; public function __construct(private Client $zendsms) {} public function notify(string $phone): void { $this->zendsms->sendSms($phone, 'YOUR_CLI', 'Your order shipped.'); }
Laravel notifications
use Illuminate\Notifications\Notification; use ZendSms\Laravel\Channels\ZendSmsChannel; class OrderShipped extends Notification { public function via($notifiable): array { return [ZendSmsChannel::class]; } public function toZendSms($notifiable): array { return [ 'to' => $notifiable->phone, // or routeNotificationForZendSms() 'sender_id' => config('zendsms.default_sender_id'), 'message' => "Order #{$this->order->id} has shipped.", 'client_ref' => (string) $this->order->id, ]; } }
On the notifiable model:
public function routeNotificationForZendSms($notification): string { return $this->phone; }
API surface
| Method | Endpoint |
|---|---|
sendSms() |
POST /api/v1/send-sms |
sendOtp() |
POST /api/v1/otp/send |
verifyOtp() |
POST /api/v1/otp/verify |
balance() |
GET /api/v1/balance |
dlr() |
GET /api/v1/dlr/{message_id} |
Full API docs: developer.zendsms.com
Errors
Failed HTTP responses throw ZendSms\Laravel\Exceptions\ZendSmsException with:
$e->getMessage()— API message$e->apiCode— business code (e.g.2201insufficient balance)$e->httpStatus— HTTP status$e->response— decoded JSON body
Testing
composer install vendor/bin/phpunit
License
MIT © Zend SMS