C# SEND

By
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");
    }
}