Go (Golang) WhatsApp API Integration
Send WhatsApp Business messages from any Go / Golang application — Gin, Echo, Fiber, gRPC services, Cloud Run, Lambda — using standard net/http and the Zaptilo REST API. Built for Indian fintech, SaaS, and ops teams running Go in production.
Why Zaptilo with Go?
- Idiomatic Go — no third-party wrapper required, just net/http
- Pay-as-you-go INR pricing — from ₹0.04 / message at volume
- No monthly subscription, no per-server fee
- Worker-pool friendly — scale to thousands of concurrent sends with goroutines
- Works with Cloud Run, Lambda, GKE, Fly.io, Railway — anywhere Go runs
- India-based support, GST-compliant invoicing
Step 1: Create a Zaptilo client
package zaptilo
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"time"
)
type Client struct {
Token string
BaseURL string
HTTP *http.Client
}
func NewClient(token string) *Client {
return &Client{
Token: token,
BaseURL: "https://web.zaptilo.ai",
HTTP: &http.Client{Timeout: 15 * time.Second},
}
}
type templatePayload struct {
Phone string `json:"phone"`
Template map[string]interface{} `json:"template"`
}
// SendTemplate posts a template message to the user.
func (c *Client) SendTemplate(phone, name, lang string, bodyValues []string) error {
params := make([]map[string]string, len(bodyValues))
for i, v := range bodyValues {
params[i] = map[string]string{"type": "text", "text": v}
}
payload := templatePayload{
Phone: phone,
Template: map[string]interface{}{
"name": name,
"language": map[string]string{"code": lang},
"components": []map[string]interface{}{
{"type": "body", "parameters": params},
},
},
}
body, err := json.Marshal(payload)
if err != nil {
return err
}
req, err := http.NewRequest("POST", c.BaseURL+"/api/send/template", bytes.NewBuffer(body))
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+c.Token)
req.Header.Set("Content-Type", "application/json")
resp, err := c.HTTP.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return fmt.Errorf("zaptilo: %s", resp.Status)
}
return nil
}Step 2: Send from a Gin handler
package main
import (
"log"
"os"
"github.com/gin-gonic/gin"
"myapp/zaptilo"
)
func main() {
wa := zaptilo.NewClient(os.Getenv("ZAPTILO_API_TOKEN"))
r := gin.Default()
r.POST("/order-placed", func(c *gin.Context) {
var body struct {
Phone string `json:"phone"`
Name string `json:"name"`
OrderID string `json:"order_id"`
}
if err := c.BindJSON(&body); err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
}
if err := wa.SendTemplate(
"91"+body.Phone,
"order_confirmation", "en",
[]string{body.Name, body.OrderID},
); err != nil {
log.Println("zaptilo:", err)
}
c.JSON(200, gin.H{"ok": true})
})
r.Run(":8080")
}Same pattern works with Echo (e.POST), Fiber (app.Post), or stdlib http.HandleFunc.
Step 3: Worker pool for bulk sends
// Bulk send with a worker pool — useful for OTPs / campaigns.
type Job struct {
Phone, Template, Lang string
Values []string
}
func worker(id int, jobs <-chan Job, wa *zaptilo.Client) {
for j := range jobs {
if err := wa.SendTemplate(j.Phone, j.Template, j.Lang, j.Values); err != nil {
log.Printf("worker %d: %v", id, err)
}
}
}
func main() {
wa := zaptilo.NewClient(os.Getenv("ZAPTILO_API_TOKEN"))
jobs := make(chan Job, 1000)
for w := 1; w <= 50; w++ {
go worker(w, jobs, wa)
}
// ... feed jobs from your queue / DB / message broker
}Use cases for Indian Go teams
Fintech OTP delivery
High-throughput OTPs from Go-based UPI / payment / KYC backends.
Razorpay webhook → WhatsApp
Payment success/failure webhook → instant WhatsApp receipt.
Microservices alerts
gRPC service triggers WhatsApp on internal events (SLA breaches, anomalies).
E-commerce backends
Order placed → goroutine sends WhatsApp confirmation without blocking response.
Data pipelines
Airflow / Argo workflows in Go — WhatsApp on threshold breach.
DevOps / on-call
Internal tool sends on-call WhatsApp on PagerDuty / OpsGenie escalation.
Frequently asked questions
How do I send WhatsApp messages from Go?
Use Go's standard net/http package to POST to the Zaptilo API endpoint with a Bearer token. The full helper function is shown above — paste it into any Go service (Gin, Echo, Fiber, gRPC) and call SendTemplate(phone, name, lang, values).
Is there an official Go SDK for Zaptilo?
Not as a published Go module — the Zaptilo REST API is simple enough that idiomatic Go code is shorter than importing a wrapper. Copy the client struct from the example above, or wrap it as an internal package in your repo.
Does Go work for WhatsApp OTP at high throughput?
Yes. Go's concurrency model (goroutines + worker pools) handles thousands of OTPs per second with minimal memory. Combined with Zaptilo's API throughput, Indian fintechs use this stack for high-volume OTP delivery — see our WhatsApp OTP API guide.
How do I handle Zaptilo webhooks in Go?
Standard net/http handler. Decode the JSON payload into a struct that mirrors Meta's status/message webhook schema, validate the signature header, then process. We can publish a sample webhook handler if you'd like — just ask.
What's the cost of the Go WhatsApp Business API for Indian businesses?
Zaptilo charges from ₹0.04 per message at volume in INR with GST invoice — no monthly subscription, no per-server fee. Go's runtime cost is essentially free, so total cost ≈ Meta's per-conversation rate + Zaptilo's per-message markup.
Can I use this with Cloud Run, Lambda, GKE?
Yes. The Zaptilo API is a plain REST call — works from any Go binary, including stateless functions on AWS Lambda, Google Cloud Run, GKE pods, Fly.io, Railway, etc.
Send WhatsApp from your Go service
Free signup. INR pricing. GST invoice. India-based support.
Get Started FreeSee also: Node.js · Python · Spring Boot · .NET · All integrations