Skip to main content
The WSAPI .NET SDK provides a strongly-typed C# client for sending WhatsApp messages, managing groups and chats, and receiving real-time events via webhooks or Server-Sent Events (SSE).

Installation

Requirements

  • .NET 8, 9 or 10
  • Valid WSAPI API key and instance ID

Quick start

Register the WSAPI client in your DI container for ASP.NET Core applications:
Then inject IWSApiClient where needed:
All API endpoints are available via the corresponding client classes in WSApi.Client.ApiClient (e.g., GroupsClient, ChatsClient, ContactsClient) or through the unified IWSApiClient interface.

Error handling

The SDK provides two method variants for every operation:
Standard methods throw exceptions when API calls fail and return the result directly on success:

Receiving events via SSE

Create a BackgroundService to handle SSE events:
Register the service in Program.cs:

Handling webhooks

Read the original request bytes before parsing JSON. Configure the same signing secret on the instance and in your application; do not compare a static authentication header.

Compatibility and recent fields

Message events (including history) expose optional AdReferral; persist message.AdReferral?.CtwaClid when present. Media requests support the current optional caption, MIME type and view-once fields. QR image methods return PNG bytes; QR text methods return the code string. Existing C# group setting property names are preserved while their JSON fields match the REST API. GroupInviteLink.InviteLink reads link; GroupJoined.GroupId reads id. Join-by-invite receives HTTP 204 and returns the requested group ID for compatibility. Contacts.UpdateAsync now uses the contact upsert endpoint. Breaking change: SynchronizeAllAsync and TrySynchronizeAllAsync have been removed from ChatsClient and IChatsClient because there is no current REST endpoint for them. Use ListAsync to list chats or RequestMessagesAsync to request history for a specific chat (and their Try variants). Account management and SSE are Cloud features, not OSS admin APIs. Create a named Cloud instance using CreateSubscriptionInstanceAsync(subscriptionId, name: "Support"); the existing cancellation-token parameter remains compatible.

GitHub

github.com/wsapi-chat/wsapi-dotnet