Send

Send an SMS message through the SendMode API.

Available HTTP Methods: POST

sm_api_icon

Parameters

Parameters

ParameterTypeDescriptionRequired
messagestringJSON string with the variables to send a SMS.Yes
Message JSON

Message JSON

ParameterTypeDescriptionRequired
messagetextstringThe content of the SMS message.Yes
recipientsarrayAn array of mobile numbers to receive the message.Yes
senderidstringThe sender id displayed on the recipients device. No
customeridstringA reference id for your message.No
scheduledatestringDate and time to schedule your message to be sent to nearest 15 minute interval.
NOTE:Must be valid datetime format.
No
Example Message JSON
{
    "messagetext":"Hello World",
    "senderid":"Sendmode",
    "recipients":["0870000000"]
}
Code Examples

Code Examples

C#
using (WebClient client = new WebClient())
{
    client.Headers.Add("Authorization", "YOUR_ACCESS_KEY");
    string[] recipients = new string[1];
    recipients[0] = "0870000000

    string message = "Hello World";
    var postJson = new JavaScriptSerializer().Serialize(new
    { 
        messagetext = message, 
        senderid = "Sendmode", 
        recipients = recipients 
    });
    byte[] response =
    client.UploadValues("https://rest.sendmode.com/v2/send", new NameValueCollection()
    {
        { "message", postJson }
    });

    string result = System.Text.Encoding.UTF8.GetString(response);
    
}
php
$arr =  array('messagetext' => 'This is a test', 'senderid' => 'SendMode', 'recipients' => array('0870000000'));

$url = 'https://rest.sendmode.com/v2/send';
$data = array('message' => json_encode($arr));

// use key 'http' even if you send the request to https://...
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n" .
            "Authorization: YOUR_ACCESS_KEY\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
Java
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("https://rest.sendmode.com/v2/send");
httppost.setHeader(HttpHeaders.AUTHORIZATION, YOUR_ACCESS_KEY);

String json = "{\"messagetext\" : \"Hello World\", \"recipients\" : [\"0870000000\"]}";
List<NameValuePair> params = new ArrayList<NameValuePair>(1);
params.add(new BasicNameValuePair("message", json));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
Response

Response

{
    "status":"OK",
    "statusCode":0,
    "acceptedDateTime":"2017-08-25T12:51:01.1808223+01:00",
    "message":{
        "senderid":"Sendmode",
        "messagetext":"Hello World",
        "customerid":null,
        "scheduledate":null,
        "recipients":["0870000000"]
    }
    
}