zaptilo / whatsapp
Zaptilo WhatsApp Business API SDK for PHP — Send text, media, and template messages via WhatsApp.
dev-main
2026-04-01 20:54 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2026-05-01 21:15:27 UTC
README
Official PHP SDK for the Zaptilo WhatsApp Business API. Send text, media, and template messages via WhatsApp with a simple, clean API.
Installation
composer require zaptilo/whatsapp
Requirements: PHP 7.4+, cURL extension, JSON extension
Quick Start
use Zaptilo\WhatsApp\Zaptilo; $zaptilo = new Zaptilo('YOUR_API_TOKEN'); // Send a text message $response = $zaptilo->sendMessage('919876543210', 'Hello from Zaptilo!');
Get your API token from the Zaptilo Dashboard under Developer Tools > Access Tokens.
Usage
Send Text Message
$zaptilo->sendMessage('919876543210', 'Hello! Your order has been confirmed.');
Send Template Message
$zaptilo->sendTemplate( '919876543210', // Phone number 'order_update', // Template name 'en', // Language ['John', 'Shipped'], // Body parameter values ['#ORD-1234'] // Header parameter values (optional) );
Send Media Message
// Send image $zaptilo->sendMedia('919876543210', 'https://example.com/photo.jpg', 'image', 'Check this out!'); // Send document $zaptilo->sendMedia('919876543210', 'https://example.com/invoice.pdf', 'document', 'Your invoice'); // Send video $zaptilo->sendMedia('919876543210', 'https://example.com/video.mp4', 'video');
List Templates
$templates = $zaptilo->getTemplates(); foreach ($templates['data'] as $template) { echo $template['name'] . ' - ' . $template['status'] . PHP_EOL; }
Check Credit Balance
$result = $zaptilo->getBalance(); echo 'Balance: ' . $result['balance'];
Verify API Token
$result = $zaptilo->verify(); echo $result['message']; // "API key is valid and active"
Error Handling
use Zaptilo\WhatsApp\Zaptilo; use Zaptilo\WhatsApp\ZaptiloException; $zaptilo = new Zaptilo('YOUR_API_TOKEN'); try { $zaptilo->sendMessage('919876543210', 'Hello!'); } catch (ZaptiloException $e) { echo 'Error: ' . $e->getMessage(); echo 'Code: ' . $e->getCode(); }
Configuration
// Custom base URL (for self-hosted or staging) $zaptilo = new Zaptilo('YOUR_TOKEN', 'https://your-domain.com'); // Custom timeout (default: 30 seconds) $zaptilo = new Zaptilo('YOUR_TOKEN', 'https://zaptilo.ai', 60);
API Reference
| Method | Description |
|---|---|
sendMessage($number, $message) |
Send a text message |
sendMedia($number, $mediaUrl, $mediaType, $caption) |
Send image, video, or document |
sendTemplate($number, $templateName, $language, $bodyValues, $headerValues) |
Send a template message |
getTemplates() |
List all approved templates |
getBalance() |
Get current credit balance |
verify() |
Verify API token and subscription status |
Laravel Integration
Add your token to .env:
ZAPTILO_API_TOKEN=your_token_here
Create a service provider or use it directly:
use Zaptilo\WhatsApp\Zaptilo; $zaptilo = new Zaptilo(env('ZAPTILO_API_TOKEN')); $zaptilo->sendMessage('919876543210', 'Hello from Laravel!');
Links
License
MIT