One call from your store
Your backend already emails customers when an order ships. Send NaatChat the same moment, and it sends the approved WhatsApp message the store owner picked for it. It keeps the update on the customer's chat so Valli can answer “where is my order?”, and starts any Rules. Works from any backend: Node, PHP, Python, Medusa, Laravel, WooCommerce custom code, anything that can make an HTTP request.
Send an event
POST /v1/events with a workspace API key (nck_…, from More → API in the app). Send the facts you have. The words live in NaatChat, so the store never hard-codes message text.
// Node 18+ (built-in fetch). No package needed.
export async function sendEvent(event, id, contact, data) {
const res = await fetch("https://api.naatchat.com/v1/events", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NAATCHAT_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": id, // the same id never sends twice
},
body: JSON.stringify({ event, contact, data }),
signal: AbortSignal.timeout(15_000),
});
// 429 or 5xx: try again later with the same id. 4xx: fix the request.
if (res.status === 429 || res.status >= 500) throw new Error(`NaatChat ${res.status}`);
return res.json(); // { status: "sent" | "no_message" | "skipped" | "failed", reason, message }
}
// When an order ships:
await sendEvent("order.shipped", `order.shipped:${shipment.id}`,
{ phone: order.phone, name: order.customerName, email: order.email, external_id: order.customerId },
{
order_number: order.number,
tracking_url: shipment.trackingUrl,
order: { id: String(order.id), order_number: order.number, total: order.total, currency: "INR" },
},
);What to send
| Field | What it is |
|---|---|
event | What happened. Lowercase words joined by ., - or _, up to 80 characters. Use your own names too. |
Idempotency-Key header (or id) | Your id for this event, like order.shipped:ship_123. The same id never runs twice, so retry freely after a timeout. A failed event runs again with the same id once the owner fixes the template. |
contact.phone | The customer's WhatsApp number. A 10-digit Indian mobile becomes +91. Also name, email, external_id (your customer id). |
contact.language | Picks that language of the template when it's approved, for example ta or hi. |
contact.marketing_opt_in | true records the customer's WhatsApp marketing consent; false withdraws it. Marketing templates only go to customers who opted in. Order updates (Utility) need no opt-in. |
data | Any facts, up to 16 KB. The owner fills template blanks from them: {order_number}, {order.total}, {items.0.title}. |
data.order | Optional order (id, order_number, total, currency, status, tracking_url, items). It updates the order NaatChat keeps for the customer, so Valli can answer order questions on WhatsApp. |
dry_run | true saves and sends nothing and returns preview with the message text. Use it in your tests. |
What comes back
202 for a new event; 200 for a repeat id (with idempotent_replay: true) or a dry run.
sent | The WhatsApp message went out. message.id matches later message.status webhooks. |
no_message | No message is picked for this event yet. It's still kept for the chat history, Valli and Rules. |
skipped | Not sent on purpose: no phone, the event is switched off, or a Marketing template without consent. reason says which. |
failed | The template is missing or not approved, a value was missing, or WhatsApp refused. reason says which. Sending the same id again retries it. |
{
"id": "evt_8k2…",
"event": "order.shipped",
"status": "sent",
"reason": null,
"contact_id": "ct_…",
"conversation_id": "conv_…",
"message": { "id": "msg_…", "template": "order_shipped", "language": "en" },
"rules_started": 0
}Errors use the usual shape { error: { code, message, request_id } }: 401 bad key, 422 invalid body (don't retry), 429 slow down, 5xx retry with the same id.
Suggested events
Use these names and the owner gets sample data and a head start on each one. Any other name works too, and shows up on the Store events page as soon as you send it.
order.placed | Order confirmation |
order.cod_confirm | Ask a cash-on-delivery buyer to confirm |
order.paid | Payment received |
order.shipped | Shipped, with the tracking link |
order.out_for_delivery | Out for delivery today |
order.delivered | Delivered (a Rule can ask for a review 3 days later) |
order.cancelled / order.refunded | Cancelled or refunded |
payment.failed | Payment didn't go through, with a pay link |
cart.abandoned | Left something in the cart (Marketing: needs opt-in) |
product.back_in_stock | Back in stock (Marketing: needs opt-in) |
customer.signup | Welcome message |
Hear back
Register a webhook in NaatChat (More → API → Webhooks) to get event.processed for every event, and message.status (delivered, read, failed) with the same idempotency_key, as event:<your id>. Every webhook is signed. See verify webhooks.
{
"type": "event.processed",
"id": "evt_8k2…",
"event": "order.shipped",
"status": "sent",
"reason": null,
"idempotency_key": "order.shipped:ship_123",
"contact_id": "ct_…",
"message_id": "msg_…"
}Before you go live
- Keep the API key in an environment variable on the server, never in the browser or app.
- Send from a background job or after your database commit, so a slow network never blocks checkout.
- Use a stable id per real-world event (the shipment id, not a timestamp), so retries are safe.
- Run once with
dry_run: true, then send one real event to your own number. - Ask the store owner to follow the setup guide to pick a template for each event.