Base URL
http://localhost:3001/api
Authentication
All API requests require a Bearer token in the Authorization header:
Authorization: Bearer <your-token>
Endpoints
Login to get access token
{
"username": "admin",
"password": "admin123"
}
Create a new WhatsApp session
{
"sessionId": "my-session"
}
Get QR code for session pairing (returns base64 data URL)
Send text message
{
"to": "08123456789",
"message": "Hello from API!"
}
Send image with caption
{
"to": "08123456789",
"imageUrl": "https://example.com/image.jpg",
"caption": "Check this out!"
}
Send document/file
{
"to": "08123456789",
"fileUrl": "https://example.com/file.pdf",
"fileName": "document.pdf",
"mimeType": "application/pdf"
}
Check if phone number is registered on WhatsApp
{
"phoneNumber": "08123456789"
}
Laravel Integration Example
// In your Laravel controller
use Illuminate\Support\Facades\Http;
public function sendWhatsAppMessage($phone, $message)
{
$response = Http::withHeaders([
'Authorization' => 'Bearer ' . config('services.whatsapp.token'),
])->post(config('services.whatsapp.url') . '/sessions/default/send', [
'to' => $phone,
'message' => $message,
]);
return $response->json();
}
WebSocket Events
Connect to ws://localhost:3001 for real-time updates:
const socket = io('http://localhost:3001');
// Listen for QR code updates
socket.on('session:my-session', (event) => {
if (event.type === 'qr') {
// Display QR code: event.data.qr
}
if (event.type === 'status') {
// Connection status: event.data.status
}
});