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 (Recommended)
{
"template_id": "261", // Replace with your template ID
"direct_number": "60121234567",
"custom_fields": { "1": "John", "2": "Promo2026" }, // Optional placeholders
"send_time": "2026-01-15 14:30:00"
}
Notes:
template_id is provided, the API automatically retrieves the template content for the user.Invalid template.message_payload and captions.{
"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! This is a normal text message.",
"direct_number" => "60123456789"
];
$options = [
"http" => [
"header" => "Content-Type: application/json\r\nX-API-KEY: $apiKey\r\n",
"method" => "POST",
"content" => json_encode($data, JSON_UNESCAPED_UNICODE)
]
];
$context = stream_context_create($options);
$response = @file_get_contents($apiUrl, false, $context);
if ($response === false) {
echo "API call failed";
} else {
echo "Response: " . $response;
}
?>
2. Image / Media Message
<?php
$apiUrl = "https://www.webwms2u.com/api/send-message.php";
$apiKey = "YOUR_API_KEY_HERE";
$data = [
"message" => "Check out this image!",
"direct_number" => "60123456789",
"message_type" => "media",
"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, JSON_UNESCAPED_UNICODE)
]
];
$context = stream_context_create($options);
$response = @file_get_contents($apiUrl, false, $context);
if ($response === false) {
echo "API call failed";
} else {
echo "Response: " . $response;
}
?>
3. Template Message with Custom Fields
<?php
$apiUrl = "https://www.webwms2u.com/api/send-message.php";
$apiKey = "YOUR_API_KEY_HERE";
$data = [
"template_id" => "261",
"direct_number" => "60121234567",
"custom_fields" => [
"1" => "John",
"2" => "Promo2026"
],
"send_time" => "2026-01-15 14:30:00"
];
$options = [
"http" => [
"header" => "Content-Type: application/json\r\nX-API-KEY: $apiKey\r\n",
"method" => "POST",
"content" => json_encode($data, JSON_UNESCAPED_UNICODE)
]
];
$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 successfully",
"platform": "meta",
"cost": 1,
"message_type": "text|media"
}
All error responses are returned as JSON. Currently, the API returns HTTP 200 OK for errors, but the success field will be false and an error message will indicate the reason.
{"success": false, "error": "Missing API key"} – No API key provided via headers, GET, or server variables.{"success": false, "error": "Invalid API key"} – API key provided but not found in user_appkey_meta or user_appkey tables.{"success": false, "error": "Message or template_id is required"} – Required fields are missing: either message or template_id not provided.{"success": false, "error": "Insufficient credits"} – User’s credits are less than 1.{"success": false, "error": "Invalid template"} – Template does not exist, belongs to another user, or is inactive.✅ Note: For a full list of all possible API responses including success and error cases, visit the API Response Guide
message_payload JSON object with relevant info.