Send SMS Endpoint

REST API endpoint to send SMS messages through WSMS plugin.

This endpoint allows you to send SMS messages through the plugin. Use it to send SMS messages to one or more recipients programmatically.

Endpoint

POST /wp-json/wpsms/v1/send

Request Parameters

ParameterTypeRequiredDescription
senderstringNoThe sender ID or phone number
recipientsstring/arrayYesPhone numbers or "subscribers" to send to subscriber groups
group_idsarrayNoArray of subscriber group IDs (when recipients is "subscribers")
messagestringYesThe SMS message content
media_urlsarrayNoArray of media URLs for MMS messages

Examples

cURL

curl --location --request POST 'https://site.com/wp-json/wpsms/v1/send' \
--header 'Content-Type: application/json' \
--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 => json_encode([
    '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
   }
}
FieldTypeDescription
messagestringSuccess message
errorarrayArray of any errors (empty on success)
data.balancenumberRemaining SMS balance

Authentication

This endpoint requires authentication. Make sure your request includes valid WordPress authentication credentials or API key.

Last updated: December 23, 2024