C# SMS integration — .NET REST samples
Ready-to-use C# HTTPS/JSON examples for SMS Gateway. Any HTTP client works—you do not need a proprietary package SDK.
.NET 5+
Compatible
REST
HTTPS + JSON
Samples
Copy into your app
Quick Start Overview
Everything you need to add SMS Gateway to your .NET app
HTTPS + JSON samples
HttpClient patterns for the SMS Gateway REST API
Easy integration
Drop samples into ASP.NET, console, or worker hosts
Error-aware samples
Examples include basic status and exception handling
.NET compatibility
Works with modern .NET and common HTTP stacks
C# Code Examples
Copy-paste C# code examples for all SMS Gateway features
Send SMS
POST /api/v1/messages with Bearer token and JSON { to, text }
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
public static class SmsGatewaySend
{
// Documented send endpoint — POST /api/v1/messages (Bearer JSON)
private const string SendUrl = "https://app.sms-gateway.app/api/v1/messages";
public static async Task SendAsync(string apiKey, string number, string message)
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
client.DefaultRequestHeaders.TryAddWithoutValidation("Idempotency-Key", Guid.NewGuid().ToString());
var json = "{\"to\":[\"" + number + "\"],\"text\":\"" + message + "\",\"type\":\"sms\"}";
using var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(SendUrl, content);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine((int)response.StatusCode + " " + body);
}
}
Bulk SMS
Several E.164 numbers in one POST /messages (to[])
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
public static class BulkSmsGateway
{
private const string SendUrl = "https://app.sms-gateway.app/api/v1/messages";
public static async Task SendManyAsync(string apiKey)
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var json = "{\"to\":[\"+14155552671\",\"+14155552672\"],\"text\":\"Hello from SMS Gateway!\",\"type\":\"sms\",\"dedupe\":true}";
using var content = new StringContent(json, Encoding.UTF8, "application/json");
var body = await (await client.PostAsync(SendUrl, content)).Content.ReadAsStringAsync();
Console.WriteLine(body);
}
}
Additional Resources
Everything you need to get started with C# SMS integration
Explore More Developer Resources
PHP SMS Integration
PHP HTTPS/JSON samples for SMS Gateway REST integration
PHP SMS integration02SMS Gateway API (overview)
Marketing overview of the SMS Gateway REST API. Live contract: https://docs.sms-gateway.app/
API documentation03SMS Webhook Integration
Complete webhook guide for incoming SMS automation and auto-reply
automate SMS with webhooksReady to Integrate?
Install the Android app, pair a SIM device, then paste the API samples into your .NET backend
