Send SMS to specified number(s), contact(s), group(s).
The method requires at least one of the parameters: to, contacts, groups.
to required | Array of strings One or multiple telephone numbers. |
contacts required | Array of items One or multiple contacts from Phonebook. |
groups required | Array of items One or multiple groups from Phonebook. |
text required | string Your text message. |
date | string <YYYY-MM-DDThh:mm:ssZ> Date when to send the SMS. If this parameter is not null SMS will be scheduled for sending at the given date and time. |
priority | integer [ 0 .. 9 ] SMS with higher priority will be queued earlier. |
encoding | string Default: "default" Enum: "unicode" "standard"
|
flash | boolean Default: false Enum: false true
|
oid | string This attribute specifies a user-defined unique ID that is assigned to a message-recipient pair. |
validity | string Default: "max" Enum: "5m" "10m" "30m" "1h" "2h" "4h" "12h" "1d" "2d" "5d" "1w" "2w" "4w" "max" How long will be the message valid. If message expires before it is received by a phone, the message will be discarded by cellular network. |
send_after | string <hh:mm> Send a message after a specified time. It can be used to prevent messages from being sent at night. |
send_before | string <hh:mm> Send a message before a specified time. It can be used to prevent messages from being sent at night. |
test | boolean Default: false Enum: false true true = Simulate message sending. Messages with that parameter will not be added to outbox and they will return ID = 0. |
modem_no | integer [ 1 .. 8 ] Sending modem number (only for multimodem devices). |
Message status
status | string |
message | string |
number | string |
id | integer |
Bad request
#include
#include
#include
int main(void) {
CURL *curl;
CURLcode res;
using namespace std;
curl = curl_easy_init();
if(curl) {
char const *path = "https://smseagleip/index.php/api/v2/messages/sms";
curl_easy_setopt(curl, CURLOPT_URL, path);
string jsonPayload = R"({
"to": ["+4812345678"],
"contacts": [12,15],
"groups": [57,35],
"text": "my message",
"date": "2022-12-27T12:20:31+05:01",
"priority": 5,
"encoding": "unicode",
"flash": true,
"oid": "123abc456def789ghi123abc456def789ghi",
"validity": "30m",
"send_after": "12:05",
"send_before": "17:15",
"test": true,
"modem_no": 2
})";
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "access-token: 0005gOjCOlMH8F2BP8");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, jsonPayload.c_str());
res = curl_easy_perform(curl);
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
return 0;
}
{
"status": "queued",
"message": "OK",
"number": "123456789",
"id": 1821
}