WhatsApp API for TypeScript

Typed fetch wrapper that works in Node 18+, Bun and Deno. No SDK needed. There is no official SDK, just one HTTP request.

Send a message with TypeScript

TypeScript
interface SendResult { success: boolean; messageId: number; status: "queued" }

async function send(): Promise<SendResult> {
  const res = await fetch("https://quackapi.com/v1/messages/chat", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": process.env.QUACKAPI_KEY!,
    },
    body: JSON.stringify({
      deviceId: 1,
      to: "923001234567",
      body: "Hello from QuackAPI",
    }),
  });
  const data = await res.json();
  if (!res.ok) throw new Error(data.message ?? `HTTP ${res.status}`);
  return data as SendResult;
}

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.

TypeScript tips

  • The SendResult interface documents the response, so your editor catches typos in messageId and status.
  • Use process.env.QUACKAPI_KEY! only after validating the variable at start-up, for example with zod.

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