Send SMS endpoint

Updated on Apr 28, 2024

Introduction

This endpoint allows you to send SMS messages through the plugin. This endpoint can be useful if you want to send SMS messages to one or more recipients, or if you need to send SMS messages for any other reason.

POST /wp-json/wpsms/v1/send

Request

Curl

curl --location --request POST 'https://site.com/wp-json/wpsms/v1/send' \
--header 'Content-Type: application/json' \
--header 'Cookie: CookieConsentPolicy=0:1; LSKey-c$CookieConsentPolicy=0:1' \
--data-raw '{
   "sender":"+15058713629",
   "recipients":"subscribers",
   "group_ids":[
      13
      4
   ],
   "message":"Hello!",
   "media_urls":[
      "https://site.com/image.jpg"
   ]
}'

PHP

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://site.com/wp-json/wpsms/v1/send',
  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 =>'{
   "sender":"+15058713629",
   "recipients":"subscribers",
   "group_ids":[
      13
      4
   ],
   "message":"Hello!",
   "media_urls":[
      "https://site.com/image.jpg"
   ]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Response:

Success

{
   "message": "Successfully send SMS!",
   "error": [
      
   ],
   "data": {
      "balance": 2
   }
}