AirboxHQ 0.3.0

dotnet add package AirboxHQ --version 0.3.0
                    
NuGet\Install-Package AirboxHQ -Version 0.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AirboxHQ" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AirboxHQ" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="AirboxHQ" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AirboxHQ --version 0.3.0
                    
#r "nuget: AirboxHQ, 0.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AirboxHQ@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AirboxHQ&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=AirboxHQ&version=0.3.0
                    
Install as a Cake Tool

Airbox .NET SDK

WhatsApp and Instagram messages through one REST API, from .NET.

Install

dotnet add package AirboxHQ

.NET 8 or newer. No dependencies.

Make the client

using Airbox;

var client = new AirboxClient(Environment.GetEnvironmentVariable("AIRBOX_API_KEY"));

A test key sends to the simulator, so you can try every call before connecting a number. Pass your own HttpClient as the third argument if you want one from IHttpClientFactory. Every call is async and takes an optional CancellationToken.

Messages

var data = await client.Messages.SendTextAsync(
    new SendTextParams { To = "+77011234567", Body = "Your order is ready" },
    new RequestOptions { IdempotencyKey = "order-1042" });

Console.WriteLine(data);

The channel is auto unless you set Channel. That is the channel the customer last wrote on. The same key never sends twice.

SendImageAsync and SendVideoAsync take a Url or a MediaId and an optional Caption. SendAudioAsync and SendVoiceAsync take a Url or a MediaId.

await client.Messages.SendImageAsync(new SendImageParams
{
    To = "+77011234567",
    Url = "https://example.com/receipt.png",
    Caption = "Your receipt",
});

SendAsync still takes a full SendMessageRequest if you want to build the body yourself. Read a message back with its status:

var message = await client.Messages.GetAsync(data.GetProperty("id").GetString()!);
Console.WriteLine(message.GetProperty("status"));

Templates

IReadOnlyList<Template> templates = await client.Templates.ListAsync();

await client.Templates.SendAsync("order_ready", new SendTemplateParams
{
    To = "+77011234567",
    Language = "ru",
    Parameters = new List<string> { "Asel", "1042" },
});

Parameters is a list of strings for numbered placeholders, or a Dictionary<string, string> for named ones. The channel is whatsapp unless you set Channel. SendAsync takes RequestOptions with an idempotency key too.

Media

await using var file = File.OpenRead("receipt.png");
Media media = await client.Media.UploadAsync(file, new UploadParams { FileName = "receipt.png", ContentType = "image/png" });

await client.Messages.SendImageAsync(new SendImageParams { To = "+77011234567", MediaId = media.Id });

byte[] bytes = await client.Media.DownloadAsync(media.Id!);

UploadAsync also takes a byte[]. The file name defaults to file, the type to application/octet-stream and the channel to whatsapp.

Contacts

Page<Contact> found = await client.Contacts.ListAsync(new ListContactsParams { Phone = "+77011234567" });
Contact contact = await client.Contacts.GetAsync(found.Data[0].Id!);

Page<ConversationMessage> page = await client.Contacts.ListMessagesAsync(contact.Id!, new ListMessagesParams { Limit = 50 });
foreach (var message in page.Data)
{
    Console.WriteLine($"{message.Direction}: {message.Text?.Body}");
}

Lists come a page at a time, newest first. While HasMore is true, pass the last item's id as After for the next page.

Consent consent = await client.Contacts.GrantConsentAsync("+77011234567");
await client.Contacts.WithdrawConsentAsync("+77011234567");

Channels

foreach (var channel in await client.Channels.ListAsync())
{
    Console.WriteLine($"{channel.Name}: {channel.Status}");
}

Test

A test key can write to your workspace as a made-up customer. A live key gets test_key_required.

InboundMessage inbound = await client.Test.InboundAsync(new InboundParams
{
    From = "+77011234567",
    Text = "When will my order be ready?",
    Name = "Asel",
});

Errors

A refused request throws Airbox.AirboxException with the API's own Code, the HTTP Status and the RequestId to quote to support.

try
{
    await client.Messages.SendTextAsync(new SendTextParams { To = "+77011234567", Body = "Hi" });
}
catch (AirboxException error)
{
    Console.WriteLine($"{error.Code} {error.Status} {error.RequestId}");
}

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 0 12/4/2026
0.2.0 0 12/4/2026
0.1.0 60 12/1/2026