SMSFlow resources
Sending SMS with C# using the SMSFlow .NET SDK
Use the official SmsFlow .NET package to authenticate, send SMS and check balance from a backend application. Keep the Client Secret in environment variables, user secrets or a secret manager.
Install and prepare a controlled test
dotnet add package SmsFlow
Set SMSFLOW_CLIENT_ID and SMSFLOW_CLIENT_SECRET in your local/backend environment. Do not put real values in source, client-side code, screenshots or public issues. Use a supported .NET project with top-level statements; the current .NET quickstart documents package compatibility.
Send using the SDK
using SmsFlow;
var client = new SmsFlowClient(new SmsFlowClientOptions
{
ClientId = Environment.GetEnvironmentVariable("SMSFLOW_CLIENT_ID")!,
ClientSecret = Environment.GetEnvironmentVariable("SMSFLOW_CLIENT_SECRET")!,
Timeout = TimeSpan.FromSeconds(30)
});
var response = await client.SendSmsAsync(new SendSmsRequest
{
CampaignName = "Website synthetic example",
Messages = new[]
{
new SmsMessage
{
Destination = "27000000000",
Content = "Your demo appointment is confirmed for 10:00."
}
}
});
Console.WriteLine(response.SendResponse?.EventId);
The destination is synthetic. Replace it only with a recipient authorised for your controlled test. A real send consumes credits. The library handles the documented authentication flow; receiving an event/reference does not establish handset delivery.
Check balance and handle errors
var balance = await client.GetBalanceAsync();
Console.WriteLine(balance.Balance);
Validate your inputs and inspect errors using the API troubleshooting reference. Preserve useful non-sensitive correlation information. Avoid logging credentials or full customer message payloads. Investigate uncertain send outcomes before retrying; do not introduce an automatic replay loop around a whole campaign.
Use the published sources
NuGet package, SDK source and issues, version support and API overview. The public library covers authentication, sending and balance; discuss other operating requirements separately.
Check segment pricing before increasing your test volume. Java and other languages can use the raw HTTP examples.
Put the example into an application workflow
- Keep the API credentials in your backend’s secret configuration.
- Associate the returned event reference with the business event that triggered the message.
- For an authentication or validation error, fix the cause before trying again. For an uncertain timeout, investigate the outcome before resending.
For 100 one-part test messages, the standard sending cost is R16 excluding VAT / R18.40 including VAT. Start with one authorised recipient, not the full list. Compare API capabilities and costs and the other supported libraries.