---
title: WhatsApp order notifications with webhooks and the REST API
description: Send order confirmations and shipping updates to WhatsApp from your
  website, ERP or app with SaleMag automation webhooks or the REST API, with
  code examples.
url: https://salemag.net/blog/whatsapp-webhooks-order-notifications
language: en
published: 2026-10-24
updated: 2026-10-24
author: SaleMag Team
tags:
  - webhooks
  - rest api
  - order notifications
  - whatsapp api
---

# WhatsApp order notifications with webhooks and the REST API

> To send order notifications to WhatsApp from your own system, either post the order to an automation's incoming webhook URL, which starts a flow that sends an approved utility template, or call SaleMag's REST API endpoint POST /api/v1/messages/send with the template name and variables. Use webhooks for no-code flows and the API for full control.

- Two routes: an automation's incoming webhook (your system posts JSON, a flow sends the message) or the REST API (your code sends the message).
- Order updates outside the 24-hour window need an approved utility template with variables for the order number and total.
- Send phone numbers in international format, such as +8801712345678.
- Signed outbound webhooks push new contacts, incoming messages and finished campaigns back to your system.
- Since 1 October 2026, Meta charges for utility templates even inside an open customer service window.

A Dhaka electronics shop sells through its own website and a Facebook Page. Website orders land in the shop's order system, and every morning someone copies the order numbers into WhatsApp one by one: "Apnar order #4512 confirm hoyeche." By the evening rush, the copying has fallen behind, and customers start asking where their confirmation is.

That copying job is exactly what webhooks and APIs are for. Your order system already knows when an order is placed, confirmed or shipped. It just needs a way to tell WhatsApp.

This guide covers both ways to do it with SaleMag, a no-code webhook route and a REST API route, with request examples, the template you need, how to verify signatures, and what these messages cost after Meta's October 2026 pricing change.

## Which route should you use for order notifications?

Use an automation's incoming webhook if you want the message designed in a visual flow, and the REST API if your developers want to control every send from code. Stores on Shopify, WooCommerce or BigCommerce can skip both and connect the store directly.

| Route | How it works | Best for | Code needed |
|---|---|---|---|
| Store connection | Connect Shopify, WooCommerce or BigCommerce; order placed, fulfilled and cancelled events start automations | Hosted stores | None |
| Automation webhook | Your system posts order JSON to a URL; a flow sends the message using values from the JSON | Custom sites, ERPs, Zapier, Make, n8n | One HTTP POST |
| REST API | Your code finds or creates the contact, then calls the send endpoint | Teams who want full control | A small integration |

Many shops start with the webhook route because the message text lives in the flow, where non-developers can edit it.

## What do you need before you start?

You need four things in place before the first notification goes out:

1. **An official WhatsApp number** connected through Meta's WhatsApp Cloud API. QR-linked numbers cannot send templates.
2. **An approved utility template** for each notification type.
3. **Customer phone numbers in international format**, such as `+8801712345678`, not `01712345678`.
4. **For the API route, a token** with the scopes you need, such as `contacts:read`, `contacts:write` and `messages:write`.

## What should an order notification template say?

Keep it factual: the order number, the total and what happens next, with no promotion. Order confirmations and shipping updates are usually approved as [utility messages](https://salemag.net/glossary/utility-message); adding an offer can get them reclassified as marketing.

```
Template name: order_confirmation
Category: Utility
Language: English

Hi {{1}}, your order {{2}} is confirmed. Total: {{3}} (cash on delivery).
We will message you again when it ships.
```

```
Template name: order_shipped
Category: Utility
Language: English

Hi {{1}}, your order {{2}} has been handed to the courier.
Track it here: {{3}}
```

You can also write templates in Bangla with Bengali as the template language. Our guide to [order status templates that get approved](https://salemag.net/blog/order-status-updates-whatsapp-templates) has more wording that passes Meta's review.

## How do you send an order notification with an automation webhook?

Create an automation with the incoming webhook trigger, post your order JSON to its URL, and add a template step that reads values from that JSON. The [automation flow builder](https://salemag.net/features/automation-flow-builder) gives each automation its own URL.

### Step 1: Create the webhook trigger

Start a new automation, choose the incoming webhook trigger and pick the **Custom** preset (Shopify and WooCommerce presets exist too). Copy the URL shown on the trigger. Optionally:

- **Signature:** set a secret and the header name your system will send, and the trigger checks an HMAC-SHA256 of the raw body.
- **Event filter:** only accept certain events, such as `order.confirmed`. The Custom preset reads the event from an `event` field in the body.
- **Field mapping:** say where the phone, email and name live if they are not at the usual paths.

### Step 2: Post the order from your system

```bash
curl -X POST "https://YOUR-SALEMAG-URL/api/webhooks/automation/YOUR-TRIGGER-TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Delivery-Id: order-4512-confirmed" \
  -d '{
    "event": "order.confirmed",
    "phone": "+8801712345678",
    "first_name": "Rafi",
    "order": { "number": "4512", "total": "৳3,250", "items": 2 }
  }'
```

SaleMag reads the phone, email and name from the payload, creates the contact if it does not exist, and starts the flow. A delivery id header such as `X-Delivery-Id` protects against duplicates if your system retries, and every delivery is logged so you can replay it.

### Step 3: Send the template with values from the payload

Add a WhatsApp template step that uses `order_confirmation`, and fill its variables with tokens from the payload:

```
{{1}} = {{contact.first_name}}
{{2}} = {{context.payload.order.number}}
{{3}} = {{context.payload.order.total}}
```

Dry-run the flow, activate it, and send a test order to your own number.

### How do you sign the webhook request?

If you turned on signature checks, sign the exact raw body you send:

```js
import crypto from "crypto"

const body = JSON.stringify(order)
const signature = crypto.createHmac("sha256", process.env.SALEMAG_WEBHOOK_SECRET)
  .update(body, "utf8")
  .digest("hex")

await fetch(webhookUrl, {
  method: "POST",
  headers: { "Content-Type": "application/json", "X-Signature": signature },
  body,
})
```

Use whatever header name you entered on the trigger. Hex and base64 encodings both work.

## How do you send an order notification with the REST API?

Find or create the contact, then call `POST /api/v1/messages/send` with the template name and variables. The [developer API](https://salemag.net/features/developer-api) uses bearer tokens and returns JSON.

### Step 1: Find or create the contact

```bash
curl -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" \
  "https://YOUR-SALEMAG-URL/api/v1/contacts?search=8801712345678"

curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"phone_e164":"+8801712345678","first_name":"Rafi"}' \
  "https://YOUR-SALEMAG-URL/api/v1/contacts"
```

Keep the contact id; you need it to send.

### Step 2: Send the template

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{
    "contact_id": 42,
    "channel": "whatsapp",
    "template_name": "order_confirmation",
    "template_vars": { "1": "Rafi", "2": "4512", "3": "৳3,250" }
  }' \
  "https://YOUR-SALEMAG-URL/api/v1/messages/send"
```

A success returns the WhatsApp message id and `"status": "sent"`. Variables are keyed by position. Two details matter:

- **Template language:** the send endpoint currently sends templates with the English (`en`) language code. For a Bangla template, start an automation instead, either through its webhook or with `POST /api/v1/automations/{id}/trigger`.
- **Rate limits:** 60 requests per minute per user, plus 60 per minute on the send endpoint. On a 429, wait for the `Retry-After` header before retrying.

The same endpoint can send SMS through your default gateway with `"channel": "sms"` and a `body`.

## How do you get SaleMag events back into your own system?

Register an HTTPS endpoint on the Webhooks page and choose events. You then receive signed JSON for `contact.created`, `message.received` and `campaign.completed`, and you can fire a `test.ping` from the dashboard. A common use is logging every incoming chat, or flagging a customer who replies "cancel" to an order message.

Verify each delivery before trusting it:

```js
function verify(rawBody, header, secret) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")))
  const expected = crypto.createHmac("sha256", secret)
    .update(`${parts.t}.${rawBody}`)
    .digest("hex")
  if (!parts.v1 || parts.v1.length !== expected.length) return false
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1))
}
```

The header is `X-Webhook-Signature: t={timestamp},v1={signature}`, signed with your `whsec_` secret. Respond within 10 seconds; failed deliveries are retried up to five times, after 1 minute, 5 minutes, 1 hour, 1 day and 1 day.

## What do WhatsApp order notifications cost now?

Each template message is charged by Meta per delivered message, by category and country, and since 1 October 2026 that includes utility templates sent inside an open customer service window. Normal replies are free up to 1,000 per business number each month, then charged. Bangladesh has its own rates on Meta's rate card, which is on Meta's [pricing page](https://developers.facebook.com/docs/whatsapp/pricing). Software plans are on the [pricing page](https://salemag.net/pricing).

So send the notifications that save a support chat, such as confirmation and shipped, and skip the ones nobody needs.

## Why do order notifications fail?

Most failures come from the template, the phone number or the account.

| Problem | Typical cause | Fix |
|---|---|---|
| Template not found | Name or language does not match the approved template | Copy the exact name; check the language |
| Wrong parameters | Variable count differs from the template | Send exactly as many values as the template has |
| 422: no E.164 phone | Contact saved as 017... | Save phones as +8801... |
| No active WhatsApp account | Number disconnected | Reconnect the number in channel setup |
| 429 | Too many requests | Respect Retry-After; queue sends |
| Message not delivered | Meta-side error | Look up the code in [WhatsApp API error codes](https://salemag.net/blog/whatsapp-api-error-codes) |

## Next steps

Get your `order_confirmation` and `order_shipped` templates approved first, since review is the slow part. Then wire one route, send ten test orders to your own phone, and read the delivery log or run log for each one. To get a token and a webhook URL, [start free](https://salemag.net/register).

## Steps

1. **Get a utility template approved**: Create an order confirmation template with variables for the name, order number and total, and submit it to Meta.
2. **Choose the route**: Use an automation's incoming webhook for a no-code flow, or the REST API if your developers want full control.
3. **Send the order data**: Post the order JSON to the webhook URL, or create or find the contact and call POST /api/v1/messages/send.
4. **Verify and monitor**: Check the delivery log or run log, verify webhook signatures, and handle 429 responses with retries.

## FAQ

### How do I send a WhatsApp message when an order is placed on my website?

Have your website post the order as JSON to a SaleMag automation's incoming webhook URL, or call the SaleMag REST API from your code. In both cases the message is an approved WhatsApp utility template, such as an order confirmation with the order number.

### Do I need an approved template for WhatsApp order notifications?

Yes, in most cases. If the customer has not messaged you in the last 24 hours, WhatsApp only accepts approved templates, and order confirmations and shipping updates are usually approved as utility templates.

### Which phone format does the SaleMag API need?

International E.164 format, such as +8801712345678. The SaleMag send endpoint returns an error if the contact has no E.164 phone number.

### Does SaleMag have a webhook for new orders?

SaleMag's outbound webhooks cover contact.created, message.received and campaign.completed. Order events from Shopify, WooCommerce or BigCommerce, or from your own system through an incoming webhook, start automations instead.

### How do I verify a SaleMag webhook signature?

Read the X-Webhook-Signature header, which has the form t={timestamp},v1={signature}, compute HMAC-SHA256 of '{timestamp}.{raw body}' with your whsec_ secret, and compare the result with v1 using a constant-time comparison.

### What are the SaleMag API rate limits?

The SaleMag API allows 60 requests per minute per user, with an extra limit of 60 per minute on POST /messages/send. A 429 response includes a Retry-After header.

### Can SaleMag send order notifications by SMS too?

Yes. The SaleMag send endpoint also sends SMS through the workspace's default SMS gateway, and automations have a Send SMS step. SMS is outbound only, so replies do not reach the SaleMag inbox.
