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 7.0 or later
  • 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

1

Create an authorization attribute

2

Create the webhook controller

3

Configure appsettings.json

GitHub

github.com/wsapi-chat/wsapi-dotnet