WhatsApp API for Go

Uses only the standard library (net/http and encoding/json). There is no official SDK, just one HTTP request.

Send a message with Go

Go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{
		"deviceId": 1,
		"to": "923001234567",
		"body": "Hello from QuackAPI",
	})

	req, _ := http.NewRequest("POST", "https://quackapi.com/v1/messages/chat", bytes.NewReader(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-api-key", os.Getenv("QUACKAPI_KEY"))

	client := &http.Client{Timeout: 15 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	var out map[string]any
	json.NewDecoder(res.Body).Decode(&out)
	fmt.Println(res.StatusCode, out) // 200 map[messageId:123 status:queued success:true]
}

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.

Go tips

  • Create one http.Client with a Timeout and reuse it, because the zero-value client has no timeout.
  • Check res.StatusCode before decoding, and read the message field on non-2xx responses.

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