Skip to main content

With the Sendapp SMS API
you can automate SMS notifications
with any platform

Designed for small and medium-sized companies,
to revolutionize communication with customers.

Free trial

WebHook Example Script

Create a script with the following content and provide its URL as WebHook.

define("Api_key", "Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

try {
    if (isset($_SERVER["HTTP_X_SG_SIGNATURE"])) {
        $hash = base64_encode(hash_hmac('Sha256', $_POST["Messages"], api_key, false));
        if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) {
            $messages = json_decode($_POST["Messages"], false);

            / ** * For example: - * $messages = [* 0 => [* "ID" => "1", * "number" => "+911234567890", * "message" => "This is a test message . ", *" deviceID "=>" 1 ", *" simSlot "=>" 0 ", *" userID "=>" 1 ", *" status "=>" Received ", *" sentDate "=>" 2018-10-20T00: 00: 00 + 02: 00 ", *" deliveredDate "=>" 2018-10-20T00: 00: 00 + 02: 00 "*" groupID "=> null *] *] * * senDate represents the date and time when the message was received on the device. * deliveredDate represents the date and time when the message was received by the server. * /

            foreach ($messages as $message) {
                if(strtolower($message["Message"]) === "Hi") {
                    // Reply to message using API or execute some commands. Possibilities are limitless.
                }
            }
        } else {
            http_response_code(401);
            error_log("Signature don't match!");
        }
    } else {
        http_response_code(400);
        error_log("Signature not found!");
    }
} catch (Exception $e) {
    error_log($e->getMessage());
}

PHP Integration

Include following code in your PHP file to start sending messages.

define("SERVER", "Https://sms.sendapp.live");
define("Api_key", "Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

define("USE_SPECIFIED", 0);
define("USE_ALL_DEVICES", 1);
define("USE_ALL_SIMS", 2);

/ ** * @param string $number The mobile number where you want to send message. * @param string $message The message you want to send .. * @param int | string $device The ID of a device you want to use to send this message. * @param int $schedule Set it to timestamp when you want to send this message. * * @return array Returns The array containing information about the message. * @throws Exception If there is an error while sending a message. * /
function sendSingleMessage($number, $message, $device = 0, $schedule = null)
{
    $url = SERVER . "/Services/send.php";
    $postData = array('Number' => $number, 'Message' => $message, 'Schedules' => $schedule, 'Key' => api_key, 'Devices' => $device);
    return sendRequest($url, $postData)["Messages"][0];
}

/ ** * @param array $messages The array containing numbers and messages. * @param int $option Set this to USE_SPECIFIED if you want to use devices and SIMs specified in devices argument. * Set this to USE_ALL_DEVICES if you want to use all available devices and their default SIM to send messages. * Set this to USE_ALL_SIMS if you want to use all available devices and all their SIMs to send messages. * @param array $devices The array of ID of devices you want to use to send these messages. * @param int $schedule Set it to timestamp when you want to send these messages. * @param bool $useRandomDevice Set it to true if you want to send messages using only one random device from selected devices. * * @return array Returns The array containing messages. * For example: - * [* 0 => [* "ID" => "1", * "number" => "+911234567890", * "message" => "This is a test message.", * " deviceID "=>" 1 ", *" simSlot "=>" 0 ", *" userID "=>" 1 ", *" status "=>" Pending ", *" sentDate "=>" 2018-10-20T00 : 00: 00 + 02: 00 ", *" deliveredDate "=> null *" groupID "=>") V5LxqyBMEbQrl9 * J$5bb4c03e8a07b7.62193871 "*] *] * @throws Exception there is an error while sending messages. * /
function SendMessages($messages, $option = USE_SPECIFIED, $devices = [], $schedule = null, $useRandomDevice = false)
{
    $url = SERVER . "/Services/send.php";
    $postData = [
        'Messages' => json_encode($messages),
        'Schedules' => $schedule,
        'Key' => api_key,
        'Devices' => json_encode($devices),
        'Option' => $option,
        'UseRandomDevice' => $useRandomDevice
    ];
    return sendRequest($url, $postData)["Messages"];
}

/ ** * @param int $listID The ID of the contacts list where you want to send this message. * @param string $message The message you want to send. * @param int $option Set this to USE_SPECIFIED if you want to use devices and SIMs specified in devices argument. * Set this to USE_ALL_DEVICES if you want to use all available devices and their default SIM to send messages. * Set this to USE_ALL_SIMS if you want to use all available devices and all their SIMs to send messages. * @param array $devices The array of ID of devices you want to use to send the message. * @param int $schedule Set it to timestamp when you want to send this message. * * @return array Returns The array containing messages. * @throws Exception If there is an error while sending messages. * /
function sendMessageToContactsList($listID, $message, $option = USE_SPECIFIED, $devices = [], $schedule = null)
{
    $url = SERVER . "/Services/send.php";
    $postData = [
        'Listid' => $listID,
        'Message' => $message,
        'Schedules' => $schedule,
        'Key' => api_key,
        'Devices' => json_encode($devices),
        'Option' => $option
    ];
    return sendRequest($url, $postData)["Messages"];
}

/ ** * @param int $id The ID of a message you want to retrieve. * * @return array The array containing a message. * @throws Exception If there is an error while getting a message. * /
function getMessageByID($id) {
    $url = SERVER . "/Services/read-messages.php";
    $postData = [
        'Key' => api_key,
        'Id' => $id
    ];
    return sendRequest($url, $postData)["Messages"][0];
}

/ ** * @param string $groupID The group ID of messages you want to retrieve. * * @return array The array containing messages. * @throws Exception If there is an error while getting messages. * /
function getMessagesByGroupID($groupID) {
    $url = SERVER . "/Services/read-messages.php";
    $postData = [
        'Key' => api_key,
        'GroupId' => $groupID
    ];
    return sendRequest($url, $postData)["Messages"];
}

/ ** * @param string $status The status of messages you want to retrieve. * @param int $startTimestamp Search for messages sent or received after this time. * @param int $endTimestamp Search for messages sent or received before this time. * * @return array The array containing messages. * @throws Exception If there is an error while getting messages. * /
function getMessagesByStatus($status, $startTimestamp, $endTimestamp)
{
    $url = SERVER . "/Services/read-messages.php";
    $postData = [
        'Key' => api_key,
        'status' => $status,
        'StartTimestamp' => $startTimestamp,
        'EndTimestamp' => $endTimestamp
    ];
    return sendRequest($url, $postData)["Messages"];
}

/ ** * @param int $listID The ID of the contacts list where you want to add this contact. * @param string $number The mobile number of the contact. * @param string $name The name of the contact. * @param bool $resubscribe Set it to true if you want to resubscribe this contact if it already exists. * * @return array The array containing a newly added contact. * @throws Exception If there is an error while adding a new contact. * /
function addContact($listID, $number, $name = null, $resubscribe = false)
{
    $url = SERVER . "/Services/manage-contacts.php";
    $postData = [
        'Key' => api_key,
        'Listid' => $listID,
        'Number' => $number,
        'Name' => $name,
        'Resubscribe' => $resubscribe
    ];
    return sendRequest($url, $postData)["Contact"];
}

/ ** * @param int $listID The ID of the contacts list from which you want to unsubscribe this contact. * @param string $number The mobile number of the contact. * * @return array The array containing the unsubscribed contact. * @throws Exception If there is an error while setting subscription to false. * /
function unsubscribeContact($listID, $number)
{
    $url = SERVER . "/Services/manage-contacts.php";
    $postData = [
        'Key' => api_key,
        'Listid' => $listID,
        'Number' => $number,
        'Unsubscribe' => false
    ];
    return sendRequest($url, $postData)["Contact"];
}

/ ** * @return string The amount of message credits left. * @throws Exception If there is an error while getting message credits. * /
function getBalance()
{
    $url = SERVER . "/Services/send.php";
    $postData = [
        'Key' => api_key,
    ];
    $credits = sendRequest($url, $postData)["Credits"];
    return is_null($credits) ? "Unlimited" : $credits;
}

function sendRequest($url, $postData)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if (curl_errno($ch)) {
        throw new Exception(curl_error($ch));
    }
    curl_close($ch);
    if ($httpCode == 200) {
        $json = json_decode($response, false);
        if ($json == false) {
            if (empty($response)) {
                throw new Exception("Missing data in request. Please provide all the required information to send messages.");
            } else {
                throw new Exception($response);
            }
        } else {
            if ($json["Success"]) {
                return $json["date"];
            } else {
                throw new Exception($json["Error"]["Message"]);
            }
        }
    } else {
        throw new Exception("HTTP Error Code: {$httpCode}");
    }
}

Send Single Message

try {
    // Send a message using the primary device.
    $msg = sendSingleMessage("+911234567890", "This is a test of single message.");

    // Send a message using the Device ID 1.
    $msg = sendSingleMessage("+911234567890", "This is a test of single message.", 1);
	
    // Send a message using the SIM in slot 1 of Device ID 1 (Represented as "1 | 0").
    // SIM slot is an index so the index of the first SIM is 0 and the index of the second SIM is 1.
    // In this example, 1 represents Device ID and 0 represents SIM slot index.
    $msg = sendSingleMessage("+911234567890", "This is a test of single message.", "1|0");

    // Send scheduled message using the primary device.
    $msg = sendSingleMessage("+911234567890", "This is a test of schedule feature.", null, strtotime("+2 minutes"));
    print_r($msg);

    echo "Successfully sent a message.";
} catch (Exception $e) {
    echo $e->getMessage();
}

Send Bulk Messages

$messages = array();

for ($i = 1; $i <= 12; $i++) {
    array_push($messages,
        [
            "Number" => "+911234567890",
            "Message" => "This is a test # {$i} of PHP version. Testing bulk message functionality."
        ]);
}

try {
    // Send messages using the primary device.
    SendMessages($messages);

    // Send messages using default SIM of all available devices. Messages will be split between all devices.
    SendMessages($messages, USE_ALL_DEVICES);
	
    // Send messages using all SIMs of all available devices. Messages will be split between all SIMs.
    SendMessages($messages, USE_ALL_SIMS);

    // Send messages using only specified devices. Messages will be split between devices or SIMs you specified.
    // If you send 12 messages using this code then 4 messages will be sent by Device ID 1, other 4 by SIM in slot 1 of 
    // Device ID 2 (Represendted as "2 | 0") and remaining 4 by SIM in slot 2 of Device ID 2 (Represendted as "2 | 1").
    SendMessages($messages, USE_SPECIFIED, [1, "2|0", "2|1"]);
    
    // Send messages on schedule using the primary device.
    SendMessages($messages, null, null, strtotime("+2 minutes"));
    
    // Send a message to contacts in contacts list with ID of 1.
    sendMessageToContactsList(1, "Test", USE_SPECIFIED, 1);
    
    // Send a message on schedule to contacts in contacts list with ID of 1.
    $msgs = sendMessageToContactsList(1, "Test", null, null, strtotime("+2 minutes"));
    
    print_r($msgs);

    echo "Successfully sent bulk messages.";
} catch (Exception $e) {
    echo $e->getMessage();
}

Get remaining message credits

try {
    $credits = getBalance();
    echo "Message Credits Remaining: {$credits}";
} catch (Exception $e) {
    echo $e->getMessage();
}

Get messages and their current status

try {
    // Get a message using the ID.
    $msg = getMessageByID(1);
    print_r($msg);

    // Get messages using the Group ID.
    $msgs = getMessagesByGroupID(') * V5LxqyBMEbQrl9 J$5bb4c03e8a07b7.62193871');
    print_r($msgs);
    
    // Get messages received in last 24 hours.
    $msgs = getMessagesByStatus("Received", time() - 86400);
    print_r($msgs);
} catch (Exception $e) {
    echo $e->getMessage();
}

Manage contacts

try {
    // Add a new contact to contacts list 1 or resubscribe the contact if it already exists.
    $contact = addContact(1, "+911234567890", "Test", false);
    print_r($contact);
    
    // Unsubscribe a contact using the mobile number.
    $contact = unsubscribeContact(1, "+911234567890");
    print_r($contact);
} catch (Exception $e) {
    echo $e->getMessage();
}



C# Integration

using System;
using System.Collections.Generic;
using System.I;
using System.Net;
using System.Text;
using System.Web;
using Gateway_Sample_Application.Properties;
using Newtonsoft.jSON;
using Newtonsoft.jSON.Linq;

namespace SMS
{
    static class API
    {
        private static readonly string Server = "Https://sms.sendapp.live"
        private static readonly string Key = "6e1bdb4ed91f3b83071dd5a520c9d226ea19245e";

        public enum Option
        {
            USE_SPECIFIED = 0,
            USE_ALL_DEVICES = 1,
            USE_ALL_SIMS = 2
        }

        /// 
        /// Send single message to specific mobile number.
        /// 
        ///  The mobile number where you want to send message. 
        ///  The message you want to send. 
        ///  The ID of a device you want to use to send this message. 
        ///  Set it to timestamp when you want to send this message. 
        ///  If there is an error while sending a message. 
        ///  The dictionary containing information about the message. 
        public static Dictionary<string, object> SendSingleMessage(string number, string message, string device = "0", long? schedule = null)
        {
            var values = new Dictionary<string, object>
            {
                { "Number", number},
                { "Message", message},
                { "Schedule", schedule },
                { "Key", Key },
                { "Devices", device }
            };

            return getMessages(GetResponse($"{Server} /services/send.php", values)["Messages"])[0];
        }

        /// 
        /// Send multiple messages to different mobile numbers.
        /// 
        ///  The array containing numbers and messages. 
        ///  Set this to USE_SPECIFIED if you want to use devices and SIMs specified in devices argument.
        /// Set this to USE_ALL_DEVICES if you want to use all available devices and their default SIM to send messages.
        /// Set this to USE_ALL_SIMS if you want to use all available devices and all their SIMs to send messages. 
        ///  The array of ID of devices you want to use to send these messages. 
        ///  Set it to timestamp when you want to send this message. 
        ///  Set it to true if you want to send messages using only one random device from selected devices. 
        ///  If there is an error while sending messages. 
        ///  The array containing messages. 
        public static Dictionary<string, object> [] SendMessages(list<Dictionary<string, string>> messages, Option options = Option.USE_SPECIFIED, string[] devices = null, long? schedule = null, bool useRandomDevice = false)
        {
            var values = new Dictionary<string, object>
            {
                { "Messages", JsonConvert.SerializeObject(messages)},
                { "Schedule", schedule },
                { "Key", Key },
                { "Devices", devices },
                { "Option", (int) options },
                { "UseRandomDevice", useRandomDevice }
            };

            return getMessages(GetResponse($"{Server} /services/send.php", values)["Messages"]);
        }

        /// 
        /// Send a message to contacts in specified contacts list.
        /// 
        ///  The ID of the contacts list where you want to send this message. 
        ///  The message you want to send. 
        ///  Set this to USE_SPECIFIED if you want to use devices and SIMs specified in devices argument.
        /// Set this to USE_ALL_DEVICES if you want to use all available devices and their default SIM to send messages.
        /// Set this to USE_ALL_SIMS if you want to use all available devices and all their SIMs to send messages. 
        ///  The array of ID of devices you want to use to send these messages. 
        ///  Set it to timestamp when you want to send this message. 
        ///  If there is an error while sending messages. 
        ///  The array containing messages. 
        public static Dictionary<string, object> [] SendMessageToContactsList(int listid, string message, Option options = Option.USE_SPECIFIED, string[] devices = null, long? schedule = null)
        {
            var values = new Dictionary<string, object>
            {
                { "Listid", listid},
                { "Message", message},
                { "Schedule", schedule },
                { "Key", Key },
                { "Devices", devices },
                { "Option", (int) options }
            };

            return getMessages(GetResponse($"{Server} /services/send.php", values)["Messages"]);
        }

        /// 
        /// Get a message using the ID.
        /// 
        ///  The ID of a message you want to retrieve. 
        ///  If there is an error while getting a message. 
        ///  The dictionary containing information about the message. 
        public static Dictionary<string, object> GetMessageByID(int id)
        {
            var values = new Dictionary<string, object>
            {
                { "Key", Key },
                { "Id", id }
            };

            return getMessages(GetResponse($"{Server} /services/read-messages.php", values)["Messages"])[0];
        }

        /// 
        /// Get messages using the Group ID.
        /// 
        ///  The group ID of messages you want to retrieve. 
        ///  If there is an error while getting messages. 
        ///  The array containing messages. 
        public static Dictionary<string, object> [] GetMessagesByGroupID(string group ID)
        {
            var values = new Dictionary<string, object>
            {
                { "Key", Key },
                { "GroupId", group ID }
            };

            return getMessages(GetResponse($"{Server} /services/read-messages.php", values)["Messages"]);
        }

        /// 
        /// Get messages using the status.
        /// 
        ///  The status of messages you want to retrieve. 
        ///  Search for messages sent or received after this time. 
        ///  Search for messages sent or received before this time. 
        ///  If there is an error while getting messages. 
        ///  The array containing messages. 
        public static Dictionary<string, object> [] GetMessagesByStatus(string status, long? startTimestamp = null, long? endTimestamp = null)
        {
            var values = new Dictionary<string, object>
            {
                { "Key", Key },
                { "status", status },
                { "StartTimestamp", startTimestamp },
                { "EndTimestamp", endTimestamp }
            };

            return getMessages(GetResponse($"{Server} /services/read-messages.php", values)["Messages"]);
        }
        
        /// 
        /// Add a new contact to contacts list.
        /// 
        ///  The ID of the contacts list where you want to add this contact. 
        ///  The mobile number of the contact. 
        ///  The name of the contact. 
        ///  Set it to true if you want to resubscribe this contact if it already exists. 
        ///  A dictionary containing details about a newly added contact. 
        public static Dictionary<string, object> AddContact(int listid, string number, string name = null, bool resubscribe = false)
        {
            var values = new Dictionary<string, object>
            {
                {"Key", Key},
                {"Listid", listid},
                {"Number", number},
                {"Name", name},
                {"Resubscribe", resubscribe ? '1' : '0'},
            };
            jobject jobject = (jobject) GetResponse($"{Server} /services/manage-contacts.php", values)["Contact"];
            return jobject.ToObject<Dictionary<string, object>> ();
        }
        
        /// 
        /// Unsubscribe a contact from the contacts list.
        /// 
        ///  The ID of the contacts list from which you want to unsubscribe this contact. 
        ///  The mobile number of the contact. 
        ///  A dictionary containing details about the unsubscribed contact. 
        public static Dictionary<string, object> UnsubscribeContact(int listid, string number)
        {
            var values = new Dictionary<string, object>
            {
                {"Key", Key},
                {"Listid", listid},
                {"Number", number},
                {"Unsubscribe", '1'}
            };
            jobject jobject = (jobject)GetResponse($"{Server} /services/manage-contacts.php", values)["Contact"];
            return jobject.ToObject<Dictionary<string, object>> ();
        }
        
        /// 
        /// Get remaining message credits.
        /// 
        ///  If there is an error while getting message credits. 
        ///  The amount of message credits left. 
        public static string GetBalance()
        {
            var values = new Dictionary<string, object>
            {
                {"Key", Key}
            };
            JToken credits = GetResponse($"{Server} /services/send.php", values)["Credits"];
            if (credits.Type != JTokenType.Null)
            {
                return credits.ToString();
            }
            return "Unlimited";
        }

        private static Dictionary<string, object> [] getMessages(JToken messagesJToken)
        {
            JArray jArray = (JArray)messagesJToken;
            var messages = new Dictionary<string, object> [jArray.Count];
            for (var index = 0; index < jArray.Count; index++)
            {
                messages[index] = jArray[index].ToObject<Dictionary<string, object>> ();
            }
            return messages;
        }

        private static JToken GetResponse(string url, Dictionary<string, object> postData)
        {
            var request = (HttpWebRequest)WebRequest.Create(url);
            var datastring = CreateDataString(postData);
            var date = Encoding.UTF8.GetBytes(datastring);

            request.Method = "POST";
            request.ContentType = "Application / x-www-form-urlencoded";
            request.ContentLength = date.Length;
            ServicePointManager.Expect100Continue = false;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            using (var stream = request.GetRequestStream())
            {
                stream.Write(date, 0, date.Length);
            }

            var response = (HttpWebResponse)request.GetResponse();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                using (StreamReader StreamReader = new StreamReader(response.GetResponseStream()))
                {
                    var jsonResponse = StreamReader.ReadToEnd();
                    try
                    {
                        jobject jobject = jobject.Parse(jsonResponse);
                        if ((bool)jobject["Success"])
                        {
                            return jobject["date"];
                        }
                        throw new Exception(jobject["Error"]["Message"].ToString());
                    }
                    catch (JsonReaderException)
                    {
                        if (string.IsNullOrEmpty(jsonResponse))
                        {
                            throw new InvalidDataException("Missing data in request. Please provide all the required information to send messages.");
                        }
                        throw new Exception(jsonResponse);
                    }
                }
            }

            throw new WebException($"HTTP Error: {(int) response.StatusCode} {response.StatusCode}");
        }

        private static string CreateDataString(Dictionary<string, object> date)
        {
            StringBuilder datastring = new StringBuilder();
            bool first = false;
            foreach (var obj in date)
            {
                if (obj.Value != null)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        datastring.Append("&");
                    }
                    datastring.Append(HttpUtility.UrlEncode(obj.Key));
                    datastring.Append("=");
                    datastring.Append(obj.Value is string[]
                        ? HttpUtility.UrlEncode(JsonConvert.SerializeObject(obj.Value))
                        : HttpUtility.UrlEncode(obj.Value.ToString()));
                }
            }
            return datastring.ToString();
        }
    }
}

Send Single Message

try
{
    // Send a message using the primary device.
    SMS.API.SendSingleMessage("+911234567890", "This is a test of single message.");

    // Send a message using the Device ID 1.
    Dictionary<string, object> message = SMS.API.SendSingleMessage("+911234567890", "This is a test of single message.", "1");
	
    // Send a message using the SIM in slot 1 of Device ID 1 (Represented as "1 | 0").
    // SIM slot is an index so the index of the first SIM is 0 and the index of the second SIM is 1.
    // In this example, 1 represents Device ID and 0 represents SIM slot index.
    Dictionary<string, object> message = SMS.API.SendSingleMessage("+911234567890", "This is a test of single message.", "1|0");

    // Send scheduled message using the primary device.
    long timestamp = (long) DateTime.UtcNow.AddMinutes(2).Subtract(new DateTime(1970, 1, 1)).totalseconds;
    Dictionary<string, object> message = SendSingleMessage(textBoxNumber.Text, textBoxMessage.Text, null, timestamp);
    
    MessageBox.Show("Successfully sent a message.");
}
catch (Exception exception)
{
    MessageBox.Show(exception.Message, "! Error", MessageBoxButtons.OK, MessageBoxIcon.error);
}

Send Bulk Messages

list<Dictionary<string, string>> messages = new list<Dictionary<string, string>> ();
for (int the = 1; the <= 12; the++)
{
    var message = new Dictionary<string, string>
    {
        { "Number", "+911234567890" },
        { "Message", "This is a test # {$i} of C# version. Testing bulk message functionality." }
    };
    messages.Add(message);
}

try
{
    // Send messages using the primary device.
    SMS.API.SendMessages(messages);

    // Send messages using default SIM of all available devices. Messages will be split between all devices.
    SMS.API.SendMessages(messages, SMS.API.Option.USE_ALL_DEVICES);
	
    // Send messages using all SIMs of all available devices. Messages will be split between all SIMs.
    SMS.API.SendMessages(messages, SMS.API.Option.USE_ALL_SIMS);

    // Send messages using only specified devices. Messages will be split between devices or SIMs you specified.
    // If you send 12 messages using this code then 4 messages will be sent by Device ID 1, other 4 by SIM in slot 1 of 
    // Device ID 2 (Represendted as "2 | 0") and remaining 4 by SIM in slot 2 of Device ID 2 (Represendted as "2 | 1").
    SMS.API.SendMessages(messages, SMS.API.Option.USE_SPECIFIED, new [] {"1", "2|0", "2|1"});
    
    // Send messages on schedule using the primary device.
    long timestamp = (long) DateTime.UtcNow.AddMinutes(2).Subtract(new DateTime(1970, 1, 1)).totalseconds;
    Dictionary<string, object> [] messages = SMS.API.SendMessages(messages, Option.USE_SPECIFIED, null, timestamp);
    
    // Send a message to contacts in contacts list with ID of 1.
    Dictionary<string, object> [] messages = SMS.API.SendMessageToContactsList(1, "Test", SMS.API.Option.USE_SPECIFIED, new [] {"1"});

    // Send a message on schedule to contacts in contacts list with ID of 1.
    Dictionary<string, object> [] messages = SMS.API.SendMessageToContactsList(1, "Test #1", Option.USE_SPECIFIED, null, timestamp);
    
    MessageBox.Show("Success");
}
catch (Exception exception)
{
    MessageBox.Show(exception.Message, "! Error", MessageBoxButtons.OK, MessageBoxIcon.error);
}

Get remaining message credits

try
{
    string credits = SMS.API.GetBalance();
    MessageBox.Show($"Message Credits Remaining: {credits}");
}
catch (Exception exception)
{
    MessageBox.Show(exception.Message, "! Error", MessageBoxButtons.OK, MessageBoxIcon.error);
}

Get messages and their current status

try 
{
    // Get a message using the ID.
    Dictionary<string, object> message = SMS.API.GetMessageByID(1);

    // Get messages using the Group ID.
    Dictionary<string, object> [] messages = SMS.API.GetMessagesByGroupID(") * V5LxqyBMEbQrl9 J$5bb4c03e8a07b7.62193871");
    
    // Get messages received in last 24 hours.
    long timestamp = (long) DateTime.UtcNow.AddHours(-24).Subtract(new DateTime(1970, 1, 1)).totalseconds;
    GetMessagesByStatus("Received", timestamp);
}
catch (Exception exception)
{
    MessageBox.Show(exception.Message, "! Error", MessageBoxButtons.OK, MessageBoxIcon.error);
}

Manage contacts

try {
    // Add a new contact to contacts list 1 or resubscribe the contact if it already exists.
    Dictionary<string, object> contact = SMS.API.AddContact(1, "+911234567890", "Test C#", false);
    
    // Unsubscribe a contact using the mobile number.
    Dictionary<string, object> contact = UnsubscribeContact(1, "+911234567890");
}
catch (Exception exception)
{
    MessageBox.Show(exception.Message, "! Error", MessageBoxButtons.OK, MessageBoxIcon.error);
}