yoni56.WhatsAppSharpSdk 1.0.2

dotnet add package yoni56.WhatsAppSharpSdk --version 1.0.2
                    
NuGet\Install-Package yoni56.WhatsAppSharpSdk -Version 1.0.2
                    
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="yoni56.WhatsAppSharpSdk" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="yoni56.WhatsAppSharpSdk" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="yoni56.WhatsAppSharpSdk" />
                    
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 yoni56.WhatsAppSharpSdk --version 1.0.2
                    
#r "nuget: yoni56.WhatsAppSharpSdk, 1.0.2"
                    
#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 yoni56.WhatsAppSharpSdk@1.0.2
                    
#: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=yoni56.WhatsAppSharpSdk&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=yoni56.WhatsAppSharpSdk&version=1.0.2
                    
Install as a Cake Tool

WhatsAppSharp

An unofficial, strongly-typed C# SDK for the WhatsApp Business Cloud API, built for .NET 10.

WhatsAPI wraps the Meta Graph API for WhatsApp Business into a clean, dependency-injectable client so you can send messages, manage templates, media, phone numbers, and business accounts, and parse incoming webhooks without hand-rolling HTTP calls.

Architecture

The solution follows Clean Architecture principles:

Domain
  ↑
Application
  ↑
Infrastructure
  ↑
SimpleInjector Composition Root / WhatsAPI.Package
Project Description
WhatsAppBusiness.Domain Core domain enums, value objects, and exceptions (no external dependencies).
WhatsAppBusiness.Application Abstractions (interfaces), request/response models, and contracts for all WhatsApp operations.
WhatsAppBusiness.Infrastructure Concrete implementations using RestSharp to call the Meta Graph API.
WhatsAppBusiness.DependencyInjection.SimpleInjector Registration extensions for wiring the client into a SimpleInjector container.
WhatsAPI.Package Combined NuGet package bundling Application, Domain, Infrastructure, and the SimpleInjector integration.

Installation

Reference the following projects/packages:

WhatsAppBusiness.Application
WhatsAppBusiness.Infrastructure
WhatsAppBusiness.DependencyInjection.SimpleInjector

Or install the combined NuGet package:

dotnet add package WhatsAPI

Configuration

using SimpleInjector;
using WhatsAppBusiness.DependencyInjection.SimpleInjector;
using WhatsAppBusiness.Infrastructure.Configuration;

var container = new Container();

container.AddWhatsAppBusiness(
	new WhatsAppOptions
	{
		AccessToken = "YOUR_ACCESS_TOKEN",
		GraphApiVersion = "vXX.X",
		PhoneNumberId = "YOUR_PHONE_NUMBER_ID",
		BusinessAccountId = "YOUR_WABA_ID"
	});

var whatsapp = container.GetInstance<IWhatsAppBusinessClient>();

WhatsAppOptions

Property Required Default Description
AccessToken Yes — Access token used to authenticate API requests.
GraphApiVersion Yes — Graph API version (e.g. v21.0).
PhoneNumberId Yes — The WhatsApp phone number identifier.
BusinessAccountId No null The WhatsApp Business Account (WABA) identifier.
BaseUrl No https://graph.facebook.com Base URL of the Graph API.
Timeout No 100s Request timeout.
MaxRetries No 3 Maximum number of retries for failed requests.

Client Entry Point

IWhatsAppBusinessClient is the top-level entry point, exposing the following service groups:

Property Service Purpose
Messages IWhatsAppMessageService Send messages (text, media, location, contacts, reactions, interactive, templates) and mark as read.
Media IWhatsAppMediaService Upload, retrieve, download, and delete media.
Templates IWhatsAppTemplateService Manage message templates.
PhoneNumbers IWhatsAppPhoneNumberService Manage phone numbers.
BusinessAccounts IWhatsAppBusinessAccountService Manage business account subscriptions and phone numbers.
Webhooks IWhatsAppWebhookService Parse and verify incoming webhook payloads.

Endpoints (API Surface)

Each service method below maps to an underlying WhatsApp Cloud Graph API call, made via the internal IWhatsAppApiClient (GET / POST / PUT / DELETE / media upload / download).

Messages — whatsapp.Messages

Method Graph API Call Description
SendTextAsync(TextMessageRequest) POST /{phone-number-id}/messages Sends a text message.
SendImageAsync(MediaMessageRequest) POST /{phone-number-id}/messages Sends an image message.
SendVideoAsync(MediaMessageRequest) POST /{phone-number-id}/messages Sends a video message.
SendAudioAsync(MediaMessageRequest) POST /{phone-number-id}/messages Sends an audio message.
SendDocumentAsync(MediaMessageRequest) POST /{phone-number-id}/messages Sends a document message.
SendStickerAsync(MediaMessageRequest) POST /{phone-number-id}/messages Sends a sticker message.
SendLocationAsync(LocationMessageRequest) POST /{phone-number-id}/messages Sends a location message.
SendContactsAsync(ContactsMessageRequest) POST /{phone-number-id}/messages Sends a contacts message.
SendReactionAsync(ReactionMessageRequest) POST /{phone-number-id}/messages Sends a reaction to a message.
SendInteractiveAsync(InteractiveMessageRequest) POST /{phone-number-id}/messages Sends an interactive message (buttons/lists).
SendTemplateAsync(TemplateMessageRequest) POST /{phone-number-id}/messages Sends a template message.
MarkAsReadAsync(string messageId) POST /{phone-number-id}/messages Marks a message as read.

All send operations return a SendMessageResponse.

Media — whatsapp.Media

Method Graph API Call Description
UploadAsync(MediaUpload) POST /{phone-number-id}/media Uploads media and returns an UploadMediaResponse.
GetAsync(string mediaId) GET /{media-id} Retrieves media metadata as a MediaInfoResponse.
DownloadAsync(string mediaUrl) GET {mediaUrl} Downloads media content as a Stream.
DeleteAsync(string mediaId) DELETE /{media-id} Deletes media.

Templates — whatsapp.Templates

Method Graph API Call Description
GetAsync(string businessAccountId) GET /{waba-id}/message_templates Lists message templates for a business account (paged).
GetAsync(string businessAccountId, string templateId) GET /{template-id} Gets a single template by identifier.
CreateAsync(string businessAccountId, CreateTemplateRequest) POST /{waba-id}/message_templates Creates a new message template.
DeleteAsync(string businessAccountId, string templateName, string? language) DELETE /{waba-id}/message_templates Deletes a template (optionally a specific language variant).

Phone Numbers — whatsapp.PhoneNumbers

Method Graph API Call Description
GetAsync(string businessAccountId) GET /{waba-id}/phone_numbers Lists phone numbers for a business account (paged).
GetByIdAsync(string phoneNumberId) GET /{phone-number-id} Gets a phone number by identifier.
RegisterAsync(string phoneNumberId, string pin) POST /{phone-number-id}/register Registers a phone number with a two-step verification PIN.
DeregisterAsync(string phoneNumberId) POST /{phone-number-id}/deregister Deregisters a phone number.

Business Accounts — whatsapp.BusinessAccounts

Method Graph API Call Description
SubscribeAsync(string businessAccountId) POST /{waba-id}/subscribed_apps Subscribes the app to webhook notifications for a business account.
GetPhoneNumbersAsync(string businessAccountId) GET /{waba-id}/phone_numbers Lists phone numbers associated with a business account.

Webhooks — whatsapp.Webhooks

Method Description
Parse(string payload) Parses a raw incoming webhook JSON payload into a strongly-typed WhatsAppWebhook.
VerifySignature(string payload, string signature, string appSecret) Verifies the X-Hub-Signature-256 header against the payload using the app secret.

Usage Examples

Send a text message

await whatsapp.Messages.SendTextAsync(
	new TextMessageRequest
	{
		To = "15551234567",
		Body = "Hello from C#"
	});

Upload and send an image

var upload = await whatsapp.Media.UploadAsync(
	new MediaUpload(File.OpenRead("photo.jpg"), "photo.jpg", "image/jpeg"));

await whatsapp.Messages.SendImageAsync(
	new MediaMessageRequest
	{
		To = "15551234567",
		MediaId = upload.Id
	});

List message templates

var templates = await whatsapp.Templates.GetAsync("YOUR_WABA_ID");

Parse an incoming webhook

var webhook = whatsapp.Webhooks.Parse(rawJsonPayload);

Project Structure

src/
  WhatsAppBusiness.Domain/                          Domain enums, value objects, exceptions
  WhatsAppBusiness.Application/                      Interfaces and request/response contracts
  WhatsAppBusiness.Infrastructure/                   RestSharp-based implementations calling the Graph API
  WhatsAppBusiness.DependencyInjection.SimpleInjector/ SimpleInjector registration extensions
  WhatsAPI.Package/                                  Combined NuGet package
tests/
  WhatsAppBusiness.UnitTests/                        Unit tests

License

See the repository for license details.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.2 112 8/25/2026