Send WhatsApp messages using your secure API key.
This single API endpoint supports both Meta Cloud API Keys and Personal Device API Keys. Based on your key type, the platform will route the message to the correct WhatsApp infrastructure automatically.
POST https://www.webwms2u.com/api/send-message.php
X-API-KEY: YOUR_API_KEY
Content-Type: application/json
message (string) – Required unless using a template. Plain text message.template_id (string) – Optional. Required for Meta if sending outside 24h window.direct_number (string) – Required. WhatsApp number in international format (e.g. 60123456789).send_time (string) – Optional. Schedule time in UTC (YYYY-MM-DD HH:MM:SS).custom_fields (array) – Optional. Only used with templates to populate variables like {{1}}, {{2}}.message_type (string) – Optional. Default is text. Can be text, media, document, location.message_payload (JSON object) – Required for media, document, location. Example for image: {"type":"image","url":"https://example.com/file.jpg"}{
"message": "Hello from the API!",
"direct_number": "60123456789"
}
2. Template Message with Custom Fields
{
"template_id": "123",
"direct_number": "60123456789",
"custom_fields": { "1": "John", "2": "Promo2025" },
"send_time": "2025-06-23 14:30:00"
}
3. Media Message (Image)
{
"message": "Check out this image",
"direct_number": "60123456789",
"message_type": "media",
"message_payload": {
"type": "image",
"url": "https://www.example.com/images/promo.jpg"
}
}
4. Document / PDF Message
{
"message": "Please see attached document",
"direct_number": "60123456789",
"message_type": "media",
"message_payload": {
"type": "document",
"url": "https://www.example.com/files/brochure.pdf"
}
}
5. Location Message
{
"message": "Our office location",
"direct_number": "60123456789",
"message_type": "media",
"message_payload": {
"type": "location",
"latitude": 3.13021923866952,
"longitude": 101.68375694232802,
"name": "WMS Cloud Office",
"address": "Brickfields, Kuala Lumpur"
}
}
<?php
$apiUrl = "https://www.webwms2u.com/api/send-message.php";
$apiKey = "YOUR_API_KEY_HERE";
$data = [
"message" => "Hello from the API!",
"direct_number" => "60123456789",
"message_type" => "media", // "text", "media", "document", "location"
"message_payload" => [
"type" => "image",
"url" => "https://www.example.com/images/promo.jpg"
]
];
$options = [
"http" => [
"header" => "Content-Type: application/json\r\nX-API-KEY: $apiKey\r\n",
"method" => "POST",
"content" => json_encode($data)
]
];
$context = stream_context_create($options);
$response = @file_get_contents($apiUrl, false, $context);
if ($response === false) {
echo "API call failed";
} else {
echo "Response: " . $response;
}
?>
{
"success": true,
"message": "Message queued",
"cost": 1
}
401 Unauthorized - Invalid or missing API key400 Bad Request - Required fields missing or invalid403 Forbidden - Insufficient credits or not allowedmessage_payload JSON object with relevant info.