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
| Parameter | Type | Required | Description |
|---|---|---|---|
sender | string | No | The sender ID or phone number |
recipients | string/array | Yes | Phone numbers or "subscribers" to send to subscriber groups |
group_ids | array | No | Array of subscriber group IDs (when recipients is "subscribers") |
message | string | Yes | The SMS message content |
media_urls | array | No | Array 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
}
}
| Field | Type | Description |
|---|---|---|
message | string | Success message |
error | array | Array of any errors (empty on success) |
data.balance | number | Remaining SMS balance |
Authentication
This endpoint requires authentication. Make sure your request includes valid WordPress authentication credentials or API key.
Related
Last updated: December 23, 2024