Meta Cloud API Guide

Send WhatsApp messages using your secure API key.

Send Message Endpoint

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.

Endpoint:
POST https://www.webwms2u.com/api/send-message.php
Headers:
X-API-KEY: YOUR_API_KEY
Content-Type: application/json
Supported Key Types:
Request Body Parameters:
Credit Usage
Example JSON Requests:
1. Plain Text Message
{
  "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:

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 Sample Code
1. Normal Text Message
<?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 Response:
{
  "success": true,
  "message": "Message queued successfully",
  "platform": "meta",
  "cost": 1,
  "message_type": "text|media"
}
Error Responses

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.

✅ Note: For a full list of all possible API responses including success and error cases, visit the API Response Guide

Notes: