The Laravel Fast2sms package provides full integration with the Fast2sms WhatsApp API. You can send session messages (simple or Meta format), template messages, and manage your WhatsApp Business Account (WABA) and templates.
The best way to send WhatsApp messages is through the fluent interface provided by the Fast2sms facade.
use Shakil\Fast2sms\Facades\Fast2sms;
Fast2sms::whatsapp()->to('919876543210')->sendText('Hello from WhatsApp!');
use Shakil\Fast2sms\Facades\Fast2sms;
// Send an image
Fast2sms::whatsapp()->to('919876543210')->sendImage('https://example.com/image.jpg', 'Optional caption');
// Send a document
Fast2sms::whatsapp()->to('919876543210')->sendDocument('https://example.com/invoice.pdf', 'invoice.pdf', 'Your invoice');
Template messages allow you to send pre-approved messages to users.
use Shakil\Fast2sms\Facades\Fast2sms;
Fast2sms::whatsapp()->to('919876543210')
->template('WELCOME_USER')
->variables(['John Doe'])
->send();
You can also use a fluent builder for session messages.
use Shakil\Fast2sms\Facades\Fast2sms;
use Shakil\Fast2sms\Enums\WhatsAppType;
Fast2sms::whatsapp()->to('919876543210')
->type(WhatsAppType::TEXT)
->body('Hello there!')
->send();
Fast2sms::whatsapp()->to('919876543210')
->type(WhatsAppType::IMAGE)
->media('https://example.com/cat.jpg')
->body('Look at this cat')
->send();
Tip:
viaWhatsApp($to)is a convenience alias forwhatsapp()->to($to)— both are equivalent.
If you need full control over the message payload (for interactive messages, locations, etc.), you can use the Meta format.
use Shakil\Fast2sms\Facades\Fast2sms;
Fast2sms::whatsapp()->sendMetaMessage('919876543210', [
'messaging_product' => 'whatsapp',
'type' => 'interactive',
'interactive' => [
'type' => 'button',
'body' => ['text' => 'Would you like to continue?'],
'action' => [
'buttons' => [
['type' => 'reply', 'reply' => ['id' => 'yes', 'title' => 'Yes']],
['type' => 'reply', 'reply' => ['id' => 'no', 'title' => 'No']],
]
]
]
]);
You can manage your templates and retrieve WABA details directly.
use Shakil\Fast2sms\Facades\Fast2sms;
// Get WABA number details
$numbers = Fast2sms::whatsapp()->getWabaDetails('number');
// Get all templates
$templates = Fast2sms::whatsapp()->manageTemplates('GET');
The package provides built-in support for faking WhatsApp messages in your tests.
use Shakil\Fast2sms\DataTransferObjects\WhatsAppParameters;
use Shakil\Fast2sms\Enums\WhatsAppType;
use Shakil\Fast2sms\Facades\Fast2sms;
public function test_it_sends_whatsapp_message()
{
Fast2sms::fake();
Fast2sms::whatsapp()->to('919876543210')
->sendText('Test message');
Fast2sms::assertWhatsAppSent(function (WhatsAppParameters $params): bool {
return $params->to === '919876543210'
&& $params->type === WhatsAppType::TEXT;
});
}
You can easily queue your WhatsApp messages to improve performance.
use Shakil\Fast2sms\Enums\WhatsAppType;
use Shakil\Fast2sms\Facades\Fast2sms;
Fast2sms::whatsapp()->to('919876543210')
->template('WELCOME_USER')
->variables(['John Doe'])
->queue();
// With custom queue configuration
Fast2sms::whatsapp()->to('919876543210')
->type(WhatsAppType::TEXT)
->body('Delayed Message')
->onQueue('high-priority')
->delay(60)
->queue();
See Notifications Guide for using WhatsApp as a Laravel notification channel.
The package supports both simplified session messages and the standard Meta API format for more advanced use cases.
The recommended way to send messages is via the whatsapp()->to(...) fluent interface on the Fast2sms facade. viaWhatsApp($to) is a convenience alias for whatsapp()->to($to).
use Shakil\Fast2sms\Facades\Fast2sms;
Fast2sms::whatsapp()->to('919876543210')->sendText('Hello World');
// Image
Fast2sms::whatsapp()->to('919876543210')->sendImage('https://example.com/image.jpg', 'Check this out');
// Document
Fast2sms::whatsapp()->to('919876543210')->sendDocument('https://example.com/file.pdf', 'filename.pdf', 'Caption');
You can also use the type() and body() methods:
use Shakil\Fast2sms\Enums\WhatsAppType;
Fast2sms::whatsapp()->to('919876543210')
->type(WhatsAppType::TEXT)
->body('Hello World')
->send();
Send a text or media message using a simplified format.
Endpoint: POST https://www.fast2sms.com/dev/whatsapp-session
| Parameter | Type | Required | Description |
|---|---|---|---|
phone_number_id |
string | Yes | The ID of the phone number sending the message. |
to |
string | Yes | Recipient mobile number (with country code). |
| Header | Value |
|---|---|
authorization |
YOUR_API_KEY |
content-type |
application/json |
{
"type": "text",
"text": {
"body": "Hello World"
}
}
{
"type": "image",
"image": {
"link": "https://example.com/image.jpg",
"caption": "Check this out"
}
}
Sends a session message within 24 hours of the user's reply using the standard Meta API format.
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/messages
| Parameter | Type | Required | Description |
|---|---|---|---|
version |
string | Yes | API Version (e.g., v24.0). |
phone_number_id |
string | Yes | Phone Number ID. |
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "919876543210",
"type": "text",
"text": {
"body": "Hello from Meta API"
}
}
textimagedocumentaudiovideostickerlocationreactioninteractive (list, quick replies, catalog, etc.)Template messages allow you to send pre-approved messages to users. You can use the simplified API or the advanced Meta format with components.
use Shakil\Fast2sms\Facades\Fast2sms;
Fast2sms::whatsapp()->to('919876543210')
->template('WELCOME_01')
->variables(['John', '1234'])
->send();
If your template has a media header, you can provide the URL:
Fast2sms::whatsapp()->to('919876543210')
->template('INVOICE_TEMPLATE')
->variables(['John'])
->media('https://example.com/invoice.pdf')
->documentFilename('invoice_123.pdf')
->send();
For full control over the template payload (e.g., buttons, specific language codes):
Fast2sms::whatsapp()->to('919876543210')
->template('custom_template')
->components([
[
'type' => 'body',
'parameters' => [
['type' => 'text', 'text' => 'John'],
],
],
[
'type' => 'button',
'sub_type' => 'url',
'index' => '0',
'parameters' => [
['type' => 'text', 'text' => 'track-123'],
],
],
])
->send();
Simplified API for sending WhatsApp template messages.
Endpoint: GET https://www.fast2sms.com/dev/whatsapp
| Parameter | Type | Required | Description |
|---|---|---|---|
authorization |
string | Yes | Your API Key. |
message_id |
integer | Yes | Fast2SMS Message ID of the template. |
phone_number_id |
string | Yes | WABA Phone Number ID. |
numbers |
string | Yes | Destination mobile number. |
variables_values |
string | No | Variable values joined with ` |
media_url |
uri | No | URL of the media if the template has a Header Media. |
document_filename |
string | No | Custom filename for PDF documents. |
{
"status": true,
"message": "Message sent successfully",
"request_id": "6a3b2c1d"
}
Manage your WhatsApp Business templates.
| Method | Endpoint | Description |
|---|---|---|
POST |
/dev/whatsapp/{version}/{waba_id}/message_templates |
Create Template |
GET |
/dev/whatsapp/{version}/{waba_id}/message_templates |
Get All Templates |
GET |
/dev/whatsapp/{version}/{waba_id}/message_templates/{template_id} |
Get Template by ID |
DELETE |
/dev/whatsapp/{version}/{waba_id}/message_templates |
Delete Template |
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{waba_id}/message_templates
Body:
{
"name": "welcome_message",
"category": "MARKETING",
"language": "en_US",
"components": [
{
"type": "BODY",
"text": "Hello {{1}}, welcome to our service!"
}
]
}
Use this API to get WABA ID, Phone Number ID, Message ID, and Meta Template ID.
Endpoint: GET https://www.fast2sms.com/dev/dlt_manager/whatsapp
| Parameter | Type | Required | Description |
|---|---|---|---|
authorization |
string | Yes | Your API Key. |
type |
string | Yes | number or template. |
{
"success": true,
"data": [
{
"waba_id": 99999999999xxxx,
"phone_number_id": 576xxxxxx,
"number": "15xxxxxxxxx",
"verified_name": "Name",
"name_status": "Approved",
"quality_rating": "GREEN",
"messaging_limit": "TIER_100K",
"platform_type": "CLOUD_API",
"connection_status": "CONNECTED"
}
]
}
Manage your WhatsApp Business Account (WABA) profiles, phone numbers, and health status.
use Shakil\Fast2sms\Facades\Fast2sms;
// Get Profile
$response = Fast2sms::whatsapp()->getBusinessProfile();
// Update Profile
$response = Fast2sms::whatsapp()->updateBusinessProfile([
'about' => 'Hello from our business!',
'description' => 'We provide great services.',
]);
// Get all phone numbers
$response = Fast2sms::whatsapp()->getPhoneNumbers();
// Get specific number details
$response = Fast2sms::whatsapp()->getPhoneNumberDetails('PHONE_NUMBER_ID');
// Get Health Status
$response = Fast2sms::whatsapp()->getWabaHealthStatus();
// Get WABA & Template IDs
$response = Fast2sms::whatsapp()->getWabaDetails('number');
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/whatsapp_business_profile
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/whatsapp_business_profile
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/whatsapp_business_profile_photo
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{waba_id}/phone_numbers
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}
Endpoint: GET https://www.fast2sms.com/dev/dlt_manager/whatsapp
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{waba_id}
Manage blocked users for your WhatsApp Business Account.
use Shakil\Fast2sms\Facades\Fast2sms;
// Single number
Fast2sms::whatsapp()->block('919876543210');
// Multiple numbers
Fast2sms::whatsapp()->block(['919876543210', '919876543211']);
Fast2sms::whatsapp()->unblock('919876543210');
$response = Fast2sms::whatsapp()->getBlockedUsers();
if ($response->isSuccess()) {
$blockedUsers = $response->data;
}
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/block_users
| Type | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| Path | version |
string | Yes | Defaults to v24.0. |
| Path | phone_number_id |
string | Yes | The ID of the phone number. |
| Query | authorization |
string | Yes | Your API Key. |
{
"data": [
{
"messaging_product": "whatsapp",
"wa_id": "16505551234"
}
],
"paging": {
"cursors": {
"before": "eyJvZAmZAzZAXQiOjAsInZAlcnNpb25JZACI6IjE3Mzc2Nzk2ODgzODM1ODQifQZDZD",
"after": "eyJvZAmZAzZAXQiOjAsInZAlcnNpb25JZACI6IjE3Mzc2Nzk2ODgzODM1ODQifQZDZD"
}
}
}
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/block_users
{
"messaging_product": "whatsapp",
"block_users": [
{
"input": "+16505551234"
}
]
}
{
"messaging_product": "whatsapp",
"block_users": {
"added_users": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
]
}
}
Endpoint: DELETE https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/block_users
{
"messaging_product": "whatsapp",
"block_users": [
{
"input": "+16505551234"
}
]
}
{
"messaging_product": "whatsapp",
"block_users": {
"removed_users": [
{
"input": "+16505551234",
"wa_id": "16505551234"
}
]
}
}
Upload media, manage media IDs, and generate QR codes for your WhatsApp Business Account.
use Shakil\Fast2sms\Facades\Fast2sms;
$response = Fast2sms::whatsapp()->uploadMedia('/path/to/file.jpg', 'image/jpeg');
if ($response->isSuccess()) {
$mediaId = $response->id;
}
QR code management is not available via the PHP SDK. Configure QR codes directly through the Fast2SMS Dashboard.
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/media/{media_id}
| Type | Parameter | Data Type | Required | Description |
|---|---|---|---|---|
| Path | version |
string | Yes | Defaults to v24.0. |
| Path | phone_number_id |
string | Yes | The ID of the phone number. |
| Path | media_id |
string | Yes | The ID of the media. |
| Query | authorization |
string | Yes | Your API Key. |
{
"messaging_product": "whatsapp",
"url": "<URL>",
"mime_type": "<MIME_TYPE>",
"sha256": "<HASH>",
"file_size": "<FILE_SIZE>",
"id": "<MEDIA_ID>"
}
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/media_handle
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
file | Yes | The media file to upload. |
messaging_product |
string | Yes | Defaults to whatsapp. |
type |
string | Yes | The MIME type of the media file. |
{
"h": "2:c2FtcGx..."
}
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/media
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
file | Yes | The media file to upload. |
messaging_product |
string | Yes | Defaults to whatsapp. |
type |
string | Yes | The MIME type of the media file. |
{
"id": "13658294123"
}
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/message_qrdls
Endpoint: GET https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/message_qrdls/{qr_code_id}
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/message_qrdls
Body:
{
"prefilled_message": "Hello",
"generate_qr_image": "SVG"
}
Endpoint: POST https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/message_qrdls/{qr_code_id}
Endpoint: DELETE https://www.fast2sms.com/dev/whatsapp/{version}/{phone_number_id}/message_qrdls/{qr_code_id}
Retrieve logs and summaries for your WhatsApp usage.
use Shakil\Fast2sms\Facades\Fast2sms;
$response = Fast2sms::whatsapp()->getLogs('2023-10-01', '2023-10-03');
if ($response->isSuccess()) {
$logs = $response->data;
}
$response = Fast2sms::whatsapp()->getSummary('2023-09-01', '2023-09-30');
if ($response->isSuccess()) {
$summary = $response->data;
// $summary['delivered'], $summary['read'], etc.
}
Fetch WhatsApp logs for the last 3 days.
Endpoint: GET https://www.fast2sms.com/dev/whatsapp_logs
| Parameter | Type | Required | Description |
|---|---|---|---|
authorization |
string | Yes | Your API Key. |
from |
date | Yes | From date in format YYYY-MM-DD. |
to |
date | Yes | To date in format YYYY-MM-DD. |
{
"success": true,
"message": "Whatsapp Logs generated successfully.",
"data": [
{
"type": "status_update",
"request_id": "NlOPxxxxxxxxxxxx",
"phone_number_id": "155xxxxxxxxxx",
"recipient_id": "916xxxxxxxxx",
"status": "delivered",
"timestamp": "1763717022",
"errors": null
}
]
}
Get WhatsApp logs summary for a 30-day interval.
Endpoint: GET https://www.fast2sms.com/dev/whatsapp_summary
| Parameter | Type | Required | Description |
|---|---|---|---|
authorization |
string | Yes | Your API Key. |
from |
date | Yes | From date in format YYYY-MM-DD. |
to |
date | Yes | To date in format YYYY-MM-DD. |
{
"success": true,
"message": "WhatsApp Summary fetched successfully.",
"data": {
"sent": 10,
"accepted": 16,
"delivered": 97,
"read": 5,
"failed": 3,
"rejected": 0,
"pending": 8
}
}
The package supports receiving delivery reports via webhooks or fetching them manually.
use Shakil\Fast2sms\Facades\Fast2sms;
$response = Fast2sms::whatsapp()->getDeliveryReport('REQUEST_ID');
if ($response->isSuccess()) {
$report = $response->data;
}
Webhook URL configuration is not available via the PHP SDK. Set your webhook URL directly in the Fast2SMS Dashboard under API Webhook → WhatsApp Webhook tab.
You can receive real-time WhatsApp delivery reports as a JSON POST object on your provided URL.
Panel configuration: Dashboard Dev API -> API Webhook -> WhatsApp Webhook tab.
{
"whatsapp_reports": [
{
"type": "incoming_message",
"message_id": "wamid.ABCD1234",
"phone_number_id": "123456789012345",
"from": "919876543210",
"timestamp": 1726642924,
"message_type": "text",
"body": "Hello, this is a customer response",
"context": {
"replied_to_message_id": "wamid.EFGH5678"
}
},
{
"type": "status_update",
"request_id": "wamid.ABCD1234",
"phone_number_id": "123456789012345",
"recipient_id": "919876543210",
"status": "delivered",
"timestamp": 1726643040,
"errors": null
}
]
}
Endpoint: GET https://www.fast2sms.com/dev/webhook/whatsapp/get
| Parameter | Type | Required | Description |
|---|---|---|---|
authorization |
string | Yes | Your API Key. |
{
"return": "true",
"data": [
{
"webhook_url": "https://your-site.com/webhook",
"webhook_status": "enable"
}
]...
How can I help you explore Laravel packages today?