When a customer sends a text message to your connected WhatsApp number, Wazapin sends a webhook delivery to your configured endpoint. Follow this guide to verify the webhook, check the message type, and retrieve the full text content from the Wazapin API.

Prerequisites

Before starting, you must:
  1. Connect a WhatsApp channel and set up an HTTPS webhook endpoint. See Webhooks overview.
  2. Configure your webhook to subscribe to the message.new event.
  3. Have your Endpoint Signing Secret (e.g., whsec_abc123...) and your API Key ready.

Processing flow

Handling an inbound message involves three primary steps:

1. Verify the signature

To secure your endpoint, check the signature headers (svix-signature, svix-timestamp, svix-id) using your signing secret. See Webhook signature verification for helper libraries.

2. Parse the payload

Verify that the message is incoming (direction: "inbound") and of type text (msg_type: "text"). Here is the JSON body payload for an inbound text event:
Inbound text payload
{
  "message_id": "9f1fd66d-c37a-4b50-a8c2-b4dca523f9c8",
  "conversation_id": "0f89b0f9-74b4-44f9-b9b6-48f6d4de57aa",
  "contact_id": "c1a2b3c4-d5e6-7890-abcd-ef1234567890",
  "channel_id": "wzp_abc123",
  "direction": "inbound",
  "from_phone": "6281234567890",
  "msg_type": "text"
}

3. Fetch the message content

Inbound webhooks are lightweight notifications and do not contain the text message body directly. Use the message_id from the payload to query the GET /v1/messages/ endpoint to retrieve the text content.

Code example

Here is how to handle the webhook and fetch the message body:
# Fetch the message record using the message_id from the webhook payload
curl -X GET "https://api.wazapin.com/v1/messages/9f1fd66d-c37a-4b50-a8c2-b4dca523f9c8" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Accept: application/json"

Troubleshooting

Why is the message body missing from the webhook?

Wazapin sends lightweight webhooks to reduce payload size and latency. You must make a follow-up GET /v1/messages/{messageID} call to read the text body.

Duplicate message deliveries

Wazapin uses at-least-once delivery for webhooks. If your server is slow to respond (takes more than 3 seconds) or returns a non-2xx status, Wazapin will retry sending the event. Always acknowledge the request with 200 OK immediately, and process the event body asynchronously.

Missing from_phone

The from_phone field is always populated in international format (e.g., 6281234567890) for inbound messages. If you receive an event without from_phone, check if the direction is set to outbound (sent message status echo).

Next steps