Send Your First Message
Learn how to send a WhatsApp message using Wazera.
Using the API
Send a Text Message
curl -X POST https://app.wazera.com/api/v1/messages/send \
-H "X-API-Key: wz_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"to": "201234567890",
"message": "Hello! This is a test message from Wazera."
}'
Response:
{
"success": true,
"data": {
"message_id": "msg_abc123",
"status": "sent",
"to": "201234567890",
"sent_at": "2024-01-15T10:30:00Z"
}
}
Send a Template Message
curl -X POST https://app.wazera.com/api/v1/messages/template \
-H "X-API-Key: wz_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"to": "201234567890",
"template": "order_confirmation",
"language": "en",
"params": {
"1": "John",
"2": "ORD-1234",
"3": "$99.00"
}
}'
Using the Laravel Package
Text Message
use Wazera\Laravel\Facades\Wazera;
$response = Wazera::sendMessage([
'to' => '201234567890',
'message' => 'Hello from my Laravel app!'
]);
if ($response->successful()) {
echo "Message sent: " . $response->messageId();
}
Template Message
$response = Wazera::sendTemplate([
'to' => '201234567890',
'template' => 'order_confirmation',
'params' => [
'name' => 'John',
'order_id' => 'ORD-1234',
'total' => '$99.00',
]
]);
Using Laravel Notifications
use Wazera\Laravel\Notifications\WhatsAppChannel;
use Wazera\Laravel\Notifications\WhatsAppMessage;
class OrderConfirmation extends Notification
{
public function via($notifiable)
{
return [WhatsAppChannel::class];
}
public function toWhatsApp($notifiable)
{
return (new WhatsAppMessage)
->to($notifiable->phone)
->template('order_confirmation')
->params(['name' => $notifiable->name]);
}
}
Using JavaScript
const response = await fetch('https://app.wazera.com/api/v1/messages/send', {
method: 'POST',
headers: {
'X-API-Key': 'wz_live_your_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: '201234567890',
message: 'Hello from JavaScript!'
})
});
const data = await response.json();
console.log(data);
Next Steps
- API Reference — Full API documentation
- Webhooks — Track message delivery
- Error Handling — Handle errors gracefully