Skip to content
PowerAPI Whatsapp

Send WhatsApp messages with C# / .NET

With HttpClient and PostAsJsonAsync, sending a WhatsApp message from .NET takes a few lines — in ASP.NET Core, worker services or Azure Functions.

Before you start

  1. Create a free account and copy your API key from Settings.
  2. Add a WhatsApp number and scan the QR code; copy its instance id.
  3. Replace YOUR_API_KEY and YOUR_INSTANCE_ID in the examples below.

1. Setup

// .NET 6+ — System.Net.Http.Json is included

2. Send a WhatsApp text message with C# / .NET

The recipient goes in to with the country code (for India, 91 followed by the 10-digit number). The response contains the message id and status.

send_text
using System.Net.Http.Json;

var apiKey = "YOUR_API_KEY";
var instanceId = "YOUR_INSTANCE_ID";

using var http = new HttpClient();
http.DefaultRequestHeaders.Add("x-api-key", apiKey);

var response = await http.PostAsJsonAsync(
    $"https://powerapiwa.com/api/v1/instances/{instanceId}/send",
    new { to = "919876543210", type = "text", message = "Hello from .NET" });

Console.WriteLine(await response.Content.ReadAsStringAsync());

Response and errors

Successful calls return {"success": true, ...}. Errors return {"success": false, "error": "..."} with a status code: 401 invalid key, 402 plan expired, 422 invalid payload, 429 daily limit reached. See the full API documentation.

Other languages

Get your API key in a minute

Free trial, no credit card. Connect your number and run the example above.