Sendexa LogoDocs
SDK
v0.1.0

.NET SDK

The official C# / .NET SDK for Sendexa. One package, one client, every API — SMS, OTP, WhatsApp, Email, Voice, and Webhook verification.

Zero Dependencies

Uses only System.Net.Http and System.Text.Json — both built into .NET 6+.

DI-Friendly

Accepts an optional HttpClient for IHttpClientFactory integration in ASP.NET Core.

Fully Async

Every API method is async with CancellationToken support throughout.

Immutable Records

Request and response types use C# records with init-only properties and nullable annotations.

Installation
Bash
dotnet add package Sendexa.SDK
Initialise the Client

Register as a singleton in your DI container and inject it where needed — the client is thread-safe and manages its own connection pool.

C#
// Program.cs
builder.Services.AddSingleton(new SendexaClient(new SendexaConfig
{
ApiKey = builder.Configuration["Sendexa:ApiKey"],
ApiSecret = builder.Configuration["Sendexa:ApiSecret"],
}));
// Or with IHttpClientFactory
builder.Services.AddHttpClient();
builder.Services.AddSingleton<SendexaClient>(sp =>
{
var http = sp.GetRequiredService<IHttpClientFactory>().CreateClient("sendexa");
return new SendexaClient(new SendexaConfig
{
ApiKey = builder.Configuration["Sendexa:ApiKey"],
ApiSecret = builder.Configuration["Sendexa:ApiSecret"],
}, http);
});
API Examples

Send single and bulk SMS messages with delivery tracking.

C#
using Sendexa.Resources;
// Send a single SMS
var resp = await client.Sms.SendAsync(new SendSmsRequest
{
To = "0244123456",
From = "MyBrand",
Message = "Your order #1234 has been confirmed!",
});
Console.WriteLine($"{resp.Data?.MessageId} {resp.Data?.Status}");
// Send bulk SMS
await client.Sms.SendBulkAsync(new SendBulkSmsRequest
{
From = "MyBrand",
Message = "Hello from MyBrand!", // shared fallback
Messages =
[
new BulkSmsMessage { To = "0244123456", Message = "Hi Alice!" },
new BulkSmsMessage { To = "0555987654" }, // uses shared message
],
});
// Check delivery status
var status = await client.Sms.GetStatusAsync(resp.Data!.MessageId!);
Console.WriteLine(status.Data?.Status); // "delivered"
// Resend a failed message
await client.Sms.ResendAsync(resp.Data.MessageId!);
Error Handling

All API errors throw a SendexaException with structured properties for easy branching.

C#
using Sendexa;
using Sendexa.Resources;
try
{
await client.Sms.SendAsync(new SendSmsRequest
{
To = "0244123456", From = "MyBrand", Message = "Hi!",
});
}
catch (SendexaException ex)
{
Console.WriteLine(ex.Status); // HTTP status e.g. 403
Console.WriteLine(ex.Code); // API code e.g. "SENDER_ID_NOT_APPROVED"
Console.WriteLine(ex.Message); // Human text e.g. "Sender ID not approved"
Console.WriteLine(ex.RequestId); // Trace ID for Sendexa support
}
PropertyTypeDescription
StatusintHTTP status code (400, 401, 403, 429…)
CodestringMachine-readable error code from the API
MessagestringHuman-readable description of the error
RequestIdstring?Sendexa trace ID — include when contacting support
Rawobject?Full raw error payload from the API