Send
Send an SMS message through the SendMode API.
Available HTTP Methods: POST

Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| message | string | JSON string with the variables to send a SMS. | Yes |

Message JSON
| Parameter | Type | Description | Required |
|---|---|---|---|
| messagetext | string | The content of the SMS message. | Yes |
| recipients | array | An array of mobile numbers to receive the message. | Yes |
| senderid | string | The sender id displayed on the recipients device. | No |
| customerid | string | A reference id for your message. | No |
| scheduledate | string | Date 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
C# - Function to Send SMS
C# Code Example - Sending SMS
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class SendmodeClient
{
private static readonly HttpClient client = new HttpClient();
private const string ApiUrl = "https://rest.sendmode.com/v2/send";
private const string ApiKey = "YOUR_ACCESS_KEY";
public static async Task SendSMS(string senderId, string recipient, string messageText)
{
var message = new
{
messagetext = messageText,
senderid = senderId,
recipients = new[] { recipient }
};
var jsonMessage = JsonConvert.SerializeObject(message);
var content = new StringContent($"message={jsonMessage}", Encoding.UTF8, "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Add("Authorization", ApiKey);
HttpResponseMessage response = await client.PostAsync(ApiUrl, content);
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
public static async Task Main(string[] args)
{
await SendSMS("your_senderid", "recipient_number", "your_message_content");
}
}
C# - Retrieve Numbers from Database and Send SMS
C# Code Example - Sending SMS from Database
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class Program
{
private static readonly HttpClient client = new HttpClient();
public static async Task SendSMS(string senderId, string recipient, string messageText)
{
string apiUrl = "https://rest.sendmode.com/v2/send";
string apiKey = "YOUR_ACCESS_KEY";
var message = new
{
messagetext = messageText,
senderid = senderId,
recipients = new[] { recipient }
};
var jsonMessage = JsonConvert.SerializeObject(message);
var content = new StringContent($"message={jsonMessage}", Encoding.UTF8, "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Add("Authorization", apiKey);
HttpResponseMessage response = await client.PostAsync(apiUrl, content);
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine($"SMS sent to {recipient}: {responseBody}");
}
public static async Task Main(string[] args)
{
string connectionString = "YourConnectionStringHere";
string storedProcedureName = "YourStoredProcedureName";
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand(storedProcedureName, connection))
{
command.CommandType = CommandType.StoredProcedure;
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string mobileNumber = reader["MobileNumber"].ToString();
string firstName = reader["FirstName"].ToString();
string message = $"Hi {firstName}, your personalized message content here.";
await SendSMS("YourSenderID", mobileNumber, message);
}
}
}
}
}
}
PHP
PHP Code Example - Sending SMS
<?php
function sendSMS($senderId, $recipient, $messageText) {
$apiUrl = 'https://rest.sendmode.com/v2/send';
$apiKey = 'YOUR_ACCESS_KEY';
$message = [
'messagetext' => $messageText,
'senderid' => $senderId,
'recipients' => [$recipient]
];
$data = http_build_query(['message' => json_encode($message)]);
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n" .
"Authorization: $apiKey\r\n",
'method' => 'POST',
'content' => $data
]
];
$context = stream_context_create($options);
$result = file_get_contents($apiUrl, false, $context);
if ($result === FALSE) {
throw new Exception('Error sending SMS');
}
echo $result;
}
// Example usage
sendSMS('your_senderid', 'recipient_number', 'your_message_content');
?>
Python
PYTHON Code Example - Sending SMS
import requests
def send_sms(sender_id, recipient, message_text):
api_url = 'https://rest.sendmode.com/v2/send'
api_key = 'YOUR_ACCESS_KEY'
message = {
'messagetext': message_text,
'senderid': sender_id,
'recipients': [recipient]
}
headers = {
'Authorization': api_key,
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.post(api_url, data={'message': json.dumps(message)}, headers=headers)
if response.status_code == 200:
print('SMS sent successfully')
else:
print(f'Failed to send SMS: {response.status_code} - {response.text}')
# Example usage
send_sms('your_senderid', 'recipient_number', 'your_message_content')
Java
JAVA Code Example - Sending SMS
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class SendmodeClient {
private static final String API_URL = "https://rest.sendmode.com/v2/send";
private static final String API_KEY = "YOUR_ACCESS_KEY";
public static void sendSMS(String senderId, String recipient, String messageText) throws Exception {
String jsonMessage = String.format(
"{\"messagetext\":\"%s\",\"senderid\":\"%s\",\"recipients\":[\"%s\"]}",
messageText, senderId, recipient
);
String urlParameters = "message=" + jsonMessage;
byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);
URL url = new URL(API_URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", API_KEY);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setDoOutput(true);
try (OutputStream os = conn.getOutputStream()) {
os.write(postData);
}
int responseCode = conn.getResponseCode();
System.out.println("Response Code: " + responseCode);
}
public static void main(String[] args) {
try {
sendSMS("your_senderid", "recipient_number", "your_message_content");
} catch (Exception e) {
e.printStackTrace();
}
}
}

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"]
}
}