Installation
- NuGet CLI
- Package Manager Console
Requirements
- .NET 8, 9 or 10
- Valid WSAPI API key and instance ID
Quick start
Dependency injection (recommended)
Register the WSAPI client in your DI container for ASP.NET Core applications:IWSApiClient where needed:
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:- Exception-based
- Try-based (non-throwing)
Standard methods throw exceptions when API calls fail and return the result directly on success:
Receiving events via SSE
Create aBackgroundService to handle SSE events:
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 optionalAdReferral; 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.