WhatsApp API for C#

Uses HttpClient and System.Net.Http.Json on .NET 6 or newer. There is no official SDK, just one HTTP request.

Send a message with C#

C#
using System.Net.Http.Json;

using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(15) };
http.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("QUACKAPI_KEY"));

var response = await http.PostAsJsonAsync("https://quackapi.com/v1/messages/chat", new {
    deviceId = 1,
    to = "923001234567",
    body = "Hello from QuackAPI",
});

Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");

Before you run it

  • Connect a device and use its numeric id as deviceId.
  • Set QUACKAPI_KEY to your wa_ key.
  • Run this on a server. Never ship the key to a browser or app.

C# tips

  • In ASP.NET register the client with IHttpClientFactory instead of creating it per request.
  • Call response.EnsureSuccessStatusCode() when you want an exception on 4xx and 5xx.

Handling errors

Non-2xx responses carry a JSON message. See the errors page for what each code means and which to retry.

Related

Last reviewed 2026-11-09. QuackAPI is an unofficial linked-device service. Acceptable use