Step 1:Create Template

Sign in the portal -> Templates -> Add New Template

Fill out the form according to the details. When creating a message template, you must have the following:

  • Message template name — Can only contain lowercase alphanumeric characters and underscores ( _ ). No other characters or white space are allowed.

  • Components of the message template — Fill in the template with the text and/or media components, including parameter placeholders, as required. Make sure it contains no newlines, tabs, or more than 4 consecutive spaces and meets the length restrictions as called out by the WhatsApp Business.

Step 2: The Template once approved, can be used in this API for further communication

URL : https://{{url}}/v5/api/index.php/addbroadcast

broadcast_name: string

brodcast_service: whatsapp_credits

template_id: This is template name of approved template

contacts: Phone Numbers with country code

message: For session message only

uploaded_image1: {{1}} 
attribute2:  {{2}}
attribute3:  {{3}}
attribute4:  {{4}}
attribute5:  {{5}}
attribute6:  {{6}}
attribute7:  {{7}}
attribute8:  {{8}}
attribute9:  {{9}}
attribute10:  {{10}}
attribute11:  {{11}}
attribute12:  {{12}}
attribute13:  {{13}}


Note:
** {{1}} is for Media Path. Ensure https:// in the URL of media. 

** Supported Media is .pdf, .jpg, .png, .mp3, .mp4

** {{2}} - {{12}} is reserved for the text values or variables in the message.

** {{13}} is reserver for Button URL in case of Dynamic Button

** Only Approved templates can be used. For Template name navigate to 
     Templates section after login the portal
   
** message attribute is used session message is to be sent, and keep template_id blank.

📘

Sample Response:

{"request_id":"611233e00aa21","status":"Queued","message":"Success","username":"user","Credits":93}

<?php

$api_key="Get it from Profile";
$mobile='911234567890';
$url="https://{{url}}/v5/api/index.php/addbroadcast";
$param =  [

'brodcast_service'=>'whatsapp_credits',
'broadcast_name'=>'name',
'template_id'=>'test',
'broadcast_message'=>'',
'schedule_date'=>'2021-06-25',
    'schedule_time'=>'12:46:31',
    'contacts'=>$mobile,
    'uploaded_image1'=>$uploaded1_1,
    'attribute2':'2'
    
] ;
$jsonval=json_encode($param);


$curl = curl_init();
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt_array($curl, array(
      CURLOPT_URL => $url,
      CURLOPT_FAILONERROR => true,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS =>$jsonval,
      CURLOPT_HTTPHEADER => array(
        'Authorization: '.  $api_key,
        'Content-Type: application/json'
      ),
    ));
     

    try
    {
       $response = curl_exec($curl); 

       if(curl_errno($curl)){
        echo json_encode(array('status' => "error", 'message' =>curl_error($curl)));
        exit(0); 
        }

       echo json_encode(array('status' => "ok", 'message' => $response));
       exit(0); 
    }
    catch(Exception $e){
        echo json_encode(array('status' => "error", 'message' => $e));
        exit(0); 
    }

?>