WhatsApp Business Cloud API

 

Note: This API uses WhatsApp Business Cloud API (Meta) to send template-based messages. All templates must be pre-approved by Meta before use.

Method: GET

Endpoint:

https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api
Parameters
Parameter Name Type Description
<apikey> Required Your unique API key for authentication. Get it from My Profile
<mobile> Required Recipient phone number(s) in international format. Use comma-separated values for multiple recipients (e.g., 919876543210,919876543211)
<templatename> Required Name of the approved WhatsApp template to use. Must be configured in your account
<mediatype> Optional Type of media for header. Options: image (default), document, video
<mediaid> Optional Media ID for header attachment. Required if mediatype is specified. Upload media first through WhatsApp Business API
<param1> Optional First dynamic parameter for template variables
<param2> Optional Second dynamic parameter for template variables
<param3> Optional Third dynamic parameter for template variables
<param4> Optional Fourth dynamic parameter for template variables
<param5> Optional Fifth dynamic parameter for template variables
Template Categories
Category Service ID Description
Marketing 18 Promotional messages and marketing campaigns
Utility 19 Account updates, order confirmations, service notifications
Authentication 21 OTP, password reset, account verification messages
Response Codes

Success Response
HTTP/1.1 200 OK
{
    "status": "success",
    "message": "Message sent successfully"
}
Error Responses
Missing Parameters (400 Bad Request)
{
    "error": "Required parameter missing",
    "details": "apikey is required"
}
Code Examples

Basic API Examples

Example 1: Basic Template Message

GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?apikey=YOUR_API_KEY&mobile=919876543210&templatename=welcome_message

Example 2: Template with Parameters

GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?apikey=YOUR_API_KEY&mobile=919876543210&templatename=order_confirmation&param1=John&param2=Order123&param3=₹1500

Example 3: Template with Media and Multiple Recipients

GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?apikey=YOUR_API_KEY&mobile=919876543210,919876543211&templatename=product_update&mediatype=image&mediaid=12345&param1=NewProduct&param2=50%OFF
Note: Media ID must be obtained by uploading the media file first through the WhatsApp Business API.

Example 4: Authentication Template

GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-auth-api?apikey=YOUR_API_KEY&mobile=919876543210&templatename=otp_verification
Use this endpoint specifically for OTP and authentication messages.

Example 5: cURL Command

curl -X GET "https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?apikey=YOUR_API_KEY&mobile=919876543210&templatename=welcome_message¶m1=John"
Programming Language Examples
C# (.NET) Example
using System.Net.Http;
using System.Threading.Tasks;

public class WhatsAppApiClient
{
    private readonly HttpClient _client = new();
    private readonly string _apiKey;

    public WhatsAppApiClient(string apiKey)
    {
        _apiKey = apiKey;
    }

    public async Task SendTemplateMessageAsync(string mobile, string templateName, string param1 = null)
    {
        var url = $"https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?apikey={_apiKey}&mobile={mobile}&templatename={templateName}";
        if (!string.IsNullOrEmpty(param1))
        {
            url += $"¶m1={Uri.EscapeDataString(param1)}";
        }

        var response = await _client.GetAsync(url);
        response.EnsureSuccessStatusCode();
        
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
PHP Example
<?php
function sendWhatsAppMessage($apiKey, $mobile, $templateName, $param1 = null) {
    $url = "https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api";
    $params = array(
        'apikey' => $apiKey,
        'mobile' => $mobile,
        'templatename' => $templateName
    );
    
    if ($param1 !== null) {
        $params['param1'] = $param1;
    }
    
    $url .= '?' . http_build_query($params);
    
    $response = file_get_contents($url);
    return $response;
}

// Usage
$result = sendWhatsAppMessage('YOUR_API_KEY', '919876543210', 'welcome_message', 'John');
echo $result;
?>
Python Example
import requests

def send_whatsapp_message(api_key: str, mobile: str, template_name: str, param1: str = None) -> str:
    params = {
        'apikey': api_key,
        'mobile': mobile,
        'templatename': template_name
    }
    
    if param1:
        params['param1'] = param1
    
    response = requests.get('https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api', params=params)
    response.raise_for_status()
    return response.text

# Usage example
try:
    result = send_whatsapp_message(
        api_key='YOUR_API_KEY',
        mobile='919876543210',
        template_name='welcome_message',
        param1='John'
    )
    print(result)
except requests.exceptions.RequestException as e:
    print(f"Error: {e}")
JavaScript Example
async function sendWhatsAppMessage(apiKey, mobile, templateName, param1 = null) {
    const params = new URLSearchParams({
        apikey: apiKey,
        mobile: mobile,
        templatename: templateName
    });
    
    if (param1) {
        params.append('param1', param1);
    }
    
    try {
        const response = await fetch(`https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?${params.toString()}`);
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        const data = await response.text();
        return data;
    } catch (error) {
        console.error('Error:', error);
        throw error;
    }
}

// Usage example
sendWhatsAppMessage('YOUR_API_KEY', '919876543210', 'welcome_message', 'John')
    .then(result => console.log(result))
    .catch(error => console.error('Error:', error));
C# (.NET) Example
using System.Net.Http;
using System.Threading.Tasks;

public class WhatsAppApiClient
{
    private readonly HttpClient _client = new();
    private readonly string _apiKey;

    public WhatsAppApiClient(string apiKey)
    {
        _apiKey = apiKey;
    }

    public async Task SendTemplateMessageAsync(string mobile, string templateName, string param1 = null)
    {
        var url = $"https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?apikey={_apiKey}&mobile={mobile}&templatename={templateName}";
        if (!string.IsNullOrEmpty(param1))
        {
            url += $"¶m1={Uri.EscapeDataString(param1)}";
        }

        var response = await _client.GetAsync(url);
        response.EnsureSuccessStatusCode();
        
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
PHP Example
<?php
function sendWhatsAppMessage($apiKey, $mobile, $templateName, $param1 = null) {
    $url = "https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api";
    $params = array(
        'apikey' => $apiKey,
        'mobile' => $mobile,
        'templatename' => $templateName
    );
    
    if ($param1 !== null) {
        $params['param1'] = $param1;
    }
    
    $url .= '?' . http_build_query($params);
    
    $response = file_get_contents($url);
    return $response;
}

// Usage
$result = sendWhatsAppMessage('YOUR_API_KEY', '919876543210', 'welcome_message', 'John');
echo $result;
?>
Python Example
import requests

def send_whatsapp_message(api_key: str, mobile: str, template_name: str, param1: str = None) -> str:
    params = {
        'apikey': api_key,
        'mobile': mobile,
        'templatename': template_name
    }
    
    if param1:
        params['param1'] = param1
    
    response = requests.get('https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api', params=params)
    response.raise_for_status()
    return response.text

# Usage example
try:
    result = send_whatsapp_message(
        api_key='YOUR_API_KEY',
        mobile='919876543210',
        template_name='welcome_message',
        param1='John'
    )
    print(result)
except requests.exceptions.RequestException as e:
    print(f"Error: {e}")
JavaScript Example
async function sendWhatsAppMessage(apiKey, mobile, templateName, param1 = null) {
    const params = new URLSearchParams({
        apikey: apiKey,
        mobile: mobile,
        templatename: templateName
    });
    
    if (param1) {
        params.append('param1', param1);
    }
    
    try {
        const response = await fetch(`https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-message-api?${params.toString()}`);
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        const data = await response.text();
        return data;
    } catch (error) {
        console.error('Error:', error);
        throw error;
    }
}

// Usage example
sendWhatsAppMessage('YOUR_API_KEY', '919876543210', 'welcome_message', 'John')
    .then(result => console.log(result))
    .catch(error => console.error('Error:', error));
Authentication APIs

Send Authentication Message
Endpoint: GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-auth-api
Parameters:
Name Type Description
apikey Required Your API authentication key
mobile Required Recipient's phone number (e.g., 919876543210)
templatename Required WhatsApp message template name
Response:
{
    "uid": "unique-identifier",
    "status": "success"
}
Example Request:
GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/send-auth-api?apikey=YOUR_API_KEY&mobile=919876543210&templatename=otp_template
Verify OTP
Endpoint: GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/verify-otp-api
Parameters:
Name Type Description
otp Required OTP received by the user
uid Required Unique identifier received from send-auth-api
Response:
"Valid OTP !"
Example Request:
GET https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api/verify-otp-api?otp=123456&uid=unique-identifier
Code Examples
C# Example:
using System.Net.Http;
using System.Threading.Tasks;

public class WhatsAppAuthApi
{
    private readonly HttpClient _client = new HttpClient();
    private const string BaseUrl = "https://smsmediaapi.hellopatna.com/api/whatsapp-cloud-api";

    public async Task SendAuthMessage(string apiKey, string mobile, string templateName)
    {
        var url = $"{BaseUrl}/send-auth-api?apikey={apiKey}&mobile={mobile}&templatename={templateName}";
        var response = await _client.GetAsync(url);
        return await response.Content.ReadAsStringAsync();
    }

    public async Task VerifyOTP(string otp, string uid)
    {
        var url = $"{BaseUrl}/verify-otp-api?otp={otp}&uid={uid}";
        var response = await _client.GetAsync(url);
        return await response.Content.ReadAsStringAsync();
    }
}
Important Notes

  • All templates must be pre-approved by Meta before use
  • Use international format for phone numbers (e.g., 919876543210)
  • Maximum 5 template parameters supported
  • Media files must be uploaded separately to get media IDs
Need Help?

Contact our support team for assistance with API integration

Contact Support