Understanding WhatsApp Webhook Verification
Meta requires your webhook endpoint to handle two types of HTTP requests: GET for endpoint challenge verification and POST for asynchronous message event delivery.
1. Webhook Challenge Handshake (PHP)
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$verifyToken = 'YOUR_SECRET_VERIFY_TOKEN';
if ($_GET['hub_mode'] === 'subscribe' && $_GET['hub_verify_token'] === $verifyToken) {
echo $_GET['hub_challenge'];
exit;
}
http_response_code(403);
exit;
}2. Avoiding Webhook Drops
Meta expects an immediate HTTP 200 OK response. Heavy database queries or AI generation should be dispatched to an asynchronous background queue (like Laravel Queues) rather than processed synchronously.