Skip to content

C#

The SMS Bridge API is plain HTTPS and JSON, so you do not need a special package. This example uses the standard HTTP client — it needs .NET 8 or newer. Official client packages are planned; until then, copy this into your project.

Send an SMS

Put your API key in the SMS_BRIDGE_KEY environment variable, and use one of your paired phone numbers as from_number.

// .NET 8+
using System.Net.Http.Json;
using System.Text.Json;

using var http = new HttpClient();
http.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("SMS_BRIDGE_KEY"));

var res = await http.PostAsJsonAsync("https://api.99billingsolutions.com/v1/messages/send", new
{
    from_number = "+15550100001",
    to_number = "+15550100002",
    content = "Your order #A12 has shipped",
});

var body = await res.Content.ReadFromJsonAsync<JsonElement>();
if (!res.IsSuccessStatusCode)
    throw new Exception($"{body.GetProperty("error_code")}: {body.GetProperty("message")}");

var data = body.GetProperty("data");
Console.WriteLine($"{data.GetProperty("id")} {data.GetProperty("status")}");

Good practice

  • Keep the key on your server, never in browser or app code.
  • Pass a unique request_id per message, so retrying after a timeout can never send twice.
  • On 429, wait for the Retry-After seconds before retrying.
  • Receive replies and delivery updates with webhooks and verify their signature.

Related