WhatsApp webhook API

JSONWebhooks

WhatsApp webhook API: get customer replies on your server

When a customer writes to your business, Koverage posts a message_received event to your server. Explore every field and all 14 event types below, then copy a handler to start.

Your server is listeningsample data
textIs my order on the way?09:15from 919876543210
button_replyTapped a reply button09:16from 919876543211
nfm_replySubmitted a Flow09:18from 919876543212
referralChat started from an ad or link09:21from 919876543213
Each event is one POST with a JSON body.
01Payload explorer

Explore the WhatsApp webhook API payload

Pick an event type. The JSON shows the message_received event for it, and a ready cURL command lets you test your own server.

Messages
Taps and forms
Source and orders
Housekeeping

Sample values. The event field holds the normalised payload and its inner fields depend on event_type. Check a real event and the Webhooks reference in your dashboard docs.

text
A customer sent text

event_typeThe kind of event. One of 14 values.
eventThe normalised payload for that event.
textReadable text. Empty when it does not apply.
fromThe sender’s phone number (msisdn).
msg_idThe platform’s message id.
timestampAn ISO date for the event.
02Routing

Route each WhatsApp webhook API event to the right place

Fourteen event types fall into four groups. Decide once what your system does for each group, and your handler stays small.

Messages
textmedialocationcontactsreaction
Your system

Show it in your inbox or support tool. text has the readable words. For media, location and contacts, read the event field.

Taps and forms
template_buttonbutton_replylist_replynfm_reply
Your system

Treat it as a choice. Move the lead, confirm the booking or save the Flow answer. Flow answers can also be read with the Flow completions endpoint.

Source and orders
orderreferral
Your system

Start your order flow for an order. Tag the lead with its source for a referral.

Housekeeping
systemunsupportederror
Your system

Log these. Alert your team on error. Never let an unsupported event crash your handler.

03Handler

A small handler for the WhatsApp webhook API

Three steps. The sample reads the documented fields and routes by event_type.

  1. Receive the POST

    Read the JSON body. The fields are event_type, event, text, from, msg_id and timestamp.

  2. Answer with 2xx

    Reply quickly, then do the slower work. Ask Koverage support for the exact response and retry rules.

  3. Route by event_type

    Send each event to the right part of your system. Keep a default branch.

04Round trip

From a customer message to your reply

The from value in the webhook is the msisdn you use to answer with the send message API.

1 Customer writes
Is my order on the way?

The customer sends a message to your WhatsApp number.

2 Webhook arrives
“event_type”: “text”, “text”: “Is my order…”, “from”: “919876543210”

Koverage posts the event to your server.

3 You answer
“type”: “text”, “contacts”: [{ “msisdn”: “919876543210” }], “text”: { “body”: “Yes, today.” }

Your server calls the send message API.

A customer wrote to youUse the webhook. Event: message_received.
You want to answerUse the send message API with from as msisdn.
You sent a messageUse the delivery report endpoint to check that one message.
05Good habits

Five habits for a reliable WhatsApp webhook

These keep your handler safe when events are empty, new or repeated.

DoDo not

Answer with a 2xx first. Do slow work after.

Call your database or the send API before you answer.

Check event_type before you read event.

Assume every event has text. It is empty when it does not apply.

Keep a default branch for types you do not handle.

Crash on unsupported or on a type you have not seen.

Save msg_id and skip a message you already processed.

Process the same msg_id twice.

Store the raw body for a few days while you test.

Guess at the payload. Read a real one.

06Go live

Test your WhatsApp webhook API before launch

Four steps take you from code to a real event on your own phone.

  1. 1
    Build the handler

    A public HTTPS address on your server that accepts a POST with a JSON body. Use the code above as a start.

  2. 2
    Test it with cURL

    Pick an event in the explorer, copy the test command and run it against your address. Check your logs.

  3. 3
    Give the address to Koverage

    Add your webhook address in your Koverage setup. Ask support if you cannot find where.

  4. 4
    Send yourself a real message

    Write to your business number from your own phone. Watch the event arrive and your handler route it.

WhatsApp webhook API: your questions answered

What is the WhatsApp webhook API?

It is how Koverage tells your server about customer activity. When a customer writes to you, Koverage sends a message_received event to your server as JSON. You do not need to keep asking for new messages.

Which fields does a message_received event have?

event_type, event, text, from, msg_id and timestamp. event_type names the kind of event, event holds the normalised payload, text holds readable text, from is the sender number, msg_id is the platform message id and timestamp is an ISO date.

Which event types can I receive?

text, media, location, contacts, reaction, template_button, button_reply, list_reply, nfm_reply, order, referral, system, unsupported and error. Always keep a default branch for any type you do not handle.

Is text always filled?

No. The text field holds readable text and is empty when it does not apply. Check event_type first, and read the event field for the full payload.

What should my server answer?

Answer quickly with a 2xx status, then do your slow work. This is good webhook practice. Ask Koverage support for the exact response and retry rules before you go live.

How do I avoid handling a message twice?

Save the msg_id of every message you process. If the same msg_id arrives again, skip it.

How do I reply after a webhook?

Use the send message API. Put the from value in contacts as the msisdn, and send your text or template.

Webhook or API call: which one do I use?

Use the webhook to learn what customers send you. Use the send message API to send. Use the delivery report endpoint to check one message you sent.

Start receiving replies with the WhatsApp webhook API

Build your handler, test it with cURL and connect it to Koverage. Need your key first? Start with the API key guide.

Scroll to Top