SmsBridge 0.11.0
dotnet add package SmsBridge --version 0.11.0
NuGet\Install-Package SmsBridge -Version 0.11.0
<PackageReference Include="SmsBridge" Version="0.11.0" />
<PackageVersion Include="SmsBridge" Version="0.11.0" />
<PackageReference Include="SmsBridge" />
paket add SmsBridge --version 0.11.0
#r "nuget: SmsBridge, 0.11.0"
#:package SmsBridge@0.11.0
#addin nuget:?package=SmsBridge&version=0.11.0
#tool nuget:?package=SmsBridge&version=0.11.0
SMSBridge
Install one SDK. Send SMS through multiple providers. Switch anytime.
SMSBridge is a provider-agnostic .NET SDK for sending SMS messages through multiple providers using one clean API.
SMSBridge is not a messaging platform. It is a developer SDK that gives .NET applications one clean interface for sending SMS through multiple providers.
Why SMSBridge?
Every SMS provider has a different SDK, a different API shape, and different error codes.
If you use Twilio today and need to switch to Vonage tomorrow, you rewrite your SMS code.
SMSBridge solves this. You install one package. You write to one interface. You switch providers by changing one configuration value.
Installation
SMSBridge requires .NET 10 or later and targets .NET 10 and .NET 11.
dotnet add package SmsBridge
Documentation
Documentation is available at:
https://teesofttech.github.io/SMSBridge/
Quick Start
1. Create a local ASP.NET Core app
Use the .NET 10 or .NET 11 SDK. Select the target explicitly so the generated project matches a framework supported by the package.
dotnet new web -n SmsBridgeExample -f net10.0
cd SmsBridgeExample
dotnet add package SmsBridge
dotnet user-secrets init
2. Configure Twilio
Add this section to appsettings.json.
{
"SmsBridge": {
"DefaultProvider": "twilio",
"Providers": {
"twilio": {
"Type": "Twilio"
}
}
}
}
Use .NET user secrets for local credentials and the Twilio sender number. Replace the placeholders with your own values.
dotnet user-secrets set "SmsBridge:Providers:twilio:AccountSid" "YOUR_ACCOUNT_SID"
dotnet user-secrets set "SmsBridge:Providers:twilio:AuthToken" "YOUR_AUTH_TOKEN"
dotnet user-secrets set "SmsBridge:Providers:twilio:From" "YOUR_TWILIO_NUMBER"
3. Send a message
Replace Program.cs with this complete minimal ASP.NET Core example. It uses
the configuration-based registration above, injects ISmsClient, and checks
the provider's result rather than treating a successful HTTP call as delivery.
The endpoint is for local testing only: protect any production sending
endpoint with authentication, authorisation, rate limiting and abuse controls.
using SmsBridge.Abstractions;
using SmsBridge.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSmsBridge(builder.Configuration.GetSection("SmsBridge"));
var app = builder.Build();
app.MapPost("/send", async (
SendRequest request,
ISmsClient smsClient,
CancellationToken cancellationToken) =>
{
if (string.IsNullOrWhiteSpace(request.PhoneNumber) ||
string.IsNullOrWhiteSpace(request.Message))
{
return Results.BadRequest(new { error = "PhoneNumber and Message are required." });
}
var result = await smsClient.SendAsync(new SmsMessage
{
To = request.PhoneNumber,
Body = request.Message
}, cancellationToken);
if (!result.Success)
{
// Record provider diagnostics securely on the server, not in the API response.
return Results.Problem(
title: "The SMS provider did not accept the message.",
statusCode: StatusCodes.Status502BadGateway);
}
return Results.Ok(new
{
provider = result.Provider,
messageId = result.ProviderMessageId,
status = result.Status.ToString()
});
});
app.Run();
public sealed record SendRequest(string PhoneNumber, string Message);
Start the example locally:
dotnet run -- --urls http://localhost:5157
Then send a request from another terminal. Replace the destination with a number you own and can receive messages on.
curl --request POST http://localhost:5157/send \
--header 'Content-Type: application/json' \
--data '{"phoneNumber":"+447700900001","message":"Hello from SMSBridge"}'
A successful SmsSendResult means the provider has accepted the request
at the reported Status; it does not guarantee that the recipient has
received the message. ProviderMessageId can be null, and can be used for
delivery correlation when supplied. On failure, inspect ErrorCode,
ErrorMessage, IsTransientFailure and MayHaveBeenAccepted. If
MayHaveBeenAccepted is true, a retry can send a duplicate.
For deployment, use your host's secret store or environment variables such as
SmsBridge__Providers__twilio__AuthToken. Never commit credentials.
Alternative: fluent registration
The quick-start app also supports fluent provider registration. Add
using SmsBridge.Options; to the same Program.cs and replace its
AddSmsBridge statement with the following. The endpoint and
ISmsClient.SendAsync call remain unchanged. Credentials still come
from user secrets or another configuration provider.
builder.Services.AddSmsBridge(options =>
{
options.DefaultProvider = "twilio";
options.Providers["twilio"] = new SmsProviderOptions
{
Type = SmsProviderType.Twilio
};
})
.UseTwilio("twilio", options =>
{
options.AccountSid = builder.Configuration["SmsBridge:Providers:twilio:AccountSid"];
options.AuthToken = builder.Configuration["SmsBridge:Providers:twilio:AuthToken"];
options.From = builder.Configuration["SmsBridge:Providers:twilio:From"];
});
All the necessary using directives are SmsBridge.Abstractions,
SmsBridge.DependencyInjection, and, for fluent registration,
SmsBridge.Options. Missing credentials cause provider registration to
fail. Configure those values before starting the app.
Runnable samples
The SDK and Basic sample target both .NET 10 and .NET 11. Run the Basic sample
with dotnet run --project samples/SmsBridge.BasicSample -f net10.0 or
-f net11.0. The switch-provider and failover samples target .NET 11,
so building those projects requires the .NET 11 SDK. Samples in this repository
reference the SDK project; the standalone quick start above installs the NuGet package.
- Basic send and optional verified Twilio callback
- Switch providers by configuration (.NET 11)
- Use a fallback provider (.NET 11)
Configuration-Based Provider Switching
Register multiple providers by adding them to appsettings.json. Keep credentials
out of the file; use user secrets, environment variables or a managed secret store.
{
"SmsBridge": {
"DefaultProvider": "twilio",
"Providers": {
"twilio": { "Type": "Twilio" },
"vonage": { "Type": "Vonage" }
}
}
}
dotnet user-secrets set "SmsBridge:Providers:vonage:ApiKey" "YOUR_VONAGE_API_KEY"
dotnet user-secrets set "SmsBridge:Providers:vonage:ApiSecret" "YOUR_VONAGE_API_SECRET"
dotnet user-secrets set "SmsBridge:Providers:vonage:From" "YOUR_SENDER_ID"
Keep the same AddSmsBridge(builder.Configuration.GetSection("SmsBridge"))
registration from the quick start. To switch, change DefaultProvider to
"vonage", with no changes to your sending code. Both providers must be
configured with valid credentials.
For a multi-provider runnable project, see the provider-switching sample (.NET 11).
Per-Message Provider Override
await smsClient.SendAsync(new SmsMessage
{
To = "+447700900000",
Body = "Hello",
Provider = "vonage" // override for this message only
});
Failover
For automatic failover, configure a primary and fallback provider and their
credentials. This example uses configuration-based registration with
the same appsettings.json and secret settings from the provider-switching
section:
{
"SmsBridge": {
"DefaultProvider": "twilio",
"EnableFailover": true,
"FailoverProvider": "vonage",
"Providers": {
"twilio": { "Type": "Twilio" },
"vonage": { "Type": "Vonage" }
}
}
}
using SmsBridge.Abstractions;
using SmsBridge.DependencyInjection;
// Inside Program.cs, after creating the WebApplicationBuilder:
builder.Services.AddSmsBridge(builder.Configuration.GetSection("SmsBridge"));
// Use the same ISmsClient.SendAsync call from the quick start.
The primary provider's failure must be transient and known not to have
accepted the message. SMSBridge suppresses failover for ambiguous connection
failures or server errors if MayHaveBeenAccepted is true, avoiding
potential duplicate deliveries. Explicit per-message provider overrides do
not trigger automatic failover.
See the runnable failover sample (.NET 11) and the failover rules.
Delivery Status Callbacks
Callback URLs can be configured for providers that support per-message delivery reports:
.UseTwilio("twilio", o =>
{
// credentials omitted
o.StatusCallbackUrl = "https://example.com/webhooks/twilio";
})
.UsePlivo("plivo", o =>
{
// credentials omitted
o.CallbackUrl = "https://example.com/webhooks/plivo";
})
.UseSinch("sinch", o =>
{
// credentials omitted
o.BaseUrl = "https://eu.sms.api.sinch.com"; // defaults to US
o.CallbackUrl = "https://example.com/webhooks/sinch";
});
Twilio, Vonage, and Plivo callbacks use flat key/value payloads. Sinch and Telnyx callbacks
use JSON payloads. Authenticate untrusted callbacks with the provider-specific verifier and
VerifyAndParse(...); calling Parse(...) or ParseJson(...) directly does not verify the
sender. The verification request preserves the exact public URL, headers, raw body, and form
or query values required by each provider's signing scheme. See the verified Twilio callback implementation and
Webhooks for complete ASP.NET Core examples,
signature checks, exact public URL handling and provider configuration.
Diagnostics and privacy
SMSBridge logs provider names, outcomes, error details and provider message IDs for operational diagnosis. It does not log message bodies or recipient phone numbers, and its OpenTelemetry activities do not contain recipient-derived hashes or correlation values.
Masking and unkeyed hashes should not be treated as anonymisation: phone-number inputs have a small, enumerable search space and can still be correlated or reversed. If an application needs recipient-level correlation, create an opaque, application-controlled identifier that is not derived from the phone number, apply an appropriate retention policy, and treat that identifier as potentially personal data.
Supported Providers
| Provider | Status |
|---|---|
| Twilio | Supported |
| Vonage | Supported |
| Sinch | Supported |
| Plivo | Supported |
| Telnyx | Supported |
| MessageBird | Supported |
| AWS SNS | Supported |
| Infobip | Supported |
| SmartSMSSolutions | Supported |
| Termii | Supported |
| Unifonic | Supported |
| Africa's Talking | Supported |
| Arkesel (SMS V2) | Supported |
| seven.io | Supported |
| Textmagic | Supported |
| Esendex | Supported |
| LINK Mobility (Common Platform) | Supported |
| Exotel | Supported |
| XCall | Supported |
| Jusibe | Supported |
| Mesaj | Supported |
| Voicebip | Supported |
| KudiSMS (Corporate SMS) | Supported |
| Sendexa | Supported |
| eSMS Africa | Supported |
| Celcom Africa | Supported |
| NextSMS | Supported |
| WinSMS | Supported |
| ClickSend | Unreleased |
| CM.com | Unreleased |
| Kaleyra | Unreleased |
| Beem | Unreleased |
| Textbelt | Unreleased |
| Wigal FROG | Unreleased |
| mNotify | Unreleased |
| BulkSMS.com | Unreleased |
| CEQUENS | Unreleased |
| Taqnyat | Unreleased |
| D7 Networks | Unreleased |
| MSG91 (template SMS) | Unreleased |
| Route Mobile (SGN JSON) | Unreleased |
| Bandwidth | Unreleased; OAuth client credentials |
Roadmap
- OpenTelemetry metrics
- Database outbox pattern
- Advanced retry policies
- Background processing
Target Frameworks
- .NET 10 (minimum)
- .NET 11
If your application still targets .NET 8 or 9, stay on the latest compatible SMSBridge release until you can retarget your application to .NET 10 or 11.
Contributing
Contributions are welcome. See CONTRIBUTING.md for guidance.
Licence
MIT. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- NSec.Cryptography (>= 25.4.0)
- OpenTelemetry.Api (>= 1.16.0)
-
net11.0
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- NSec.Cryptography (>= 25.4.0)
- OpenTelemetry.Api (>= 1.16.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.