brooklyn88ua
03/09/2025, 9:51 PMReece - Integration @ Retell AI
03/09/2025, 11:54 PMReece - Integration @ Retell AI
03/09/2025, 11:54 PMcrystaldev1003
03/10/2025, 1:57 AMcrystaldev1003
03/10/2025, 1:57 AMReece - Integration @ Retell AI
03/10/2025, 4:27 AMReece - Integration @ Retell AI
03/10/2025, 4:27 AMReece - Integration @ Retell AI
03/10/2025, 4:28 AMReece - Integration @ Retell AI
03/10/2025, 4:29 AMReece - Integration @ Retell AI
03/10/2025, 4:29 AMsi2026_40031
03/10/2025, 11:56 PMpublic static function verifyRetellWebhook($payload, $signature, $apiKey, $logFile)
{
$apiKey = trim($apiKey);
if (empty($apiKey))
{
error_log("Retell API key not configured\n", 3, $logFile);
return false;
}
// Ensure API key is UTF-8 encoded
$apiKey = mb_convert_encoding($apiKey, 'UTF-8');
// Parse the signature header (e.g., "v=1741628797736,d=ff1454ca...")
$signatureParts = [];
parse_str(str_replace(',', '&', $signature), $signatureParts);
// Extract the digest (d=) and timestamp (v=) from the header
$receivedDigest = $signatureParts['d'] ?? '';
$timestamp = $signatureParts['v'] ?? '';
if (empty($receivedDigest))
{
error_log("Invalid signature format: missing digest\n", 3, $logFile);
return false;
}
if (empty($timestamp))
{
error_log("Invalid signature format: missing timestamp\n", 3, $logFile);
return false;
}
// Ensure payload is UTF-8 encoded
$payload = mb_convert_encoding($payload, 'UTF-8');
// Compute the expected HMAC-SHA256 signature
$dataToSign = $payload . $timestamp;
$expectedSignature = hash_hmac('sha256', $dataToSign, $apiKey);
// Compare the computed signature with the received digest
return hash_equals($expectedSignature, $receivedDigest);
}Reece - Integration @ Retell AI
03/10/2025, 11:57 PMsi2026_40031
03/10/2025, 11:58 PM$signature = $_SERVER['HTTP_X_RETELL_SIGNATURE'] ?? '';
$apiKey = "Your API key";
$logFile = __DIR__ . '/webhook_errors.log';
if (!verifyRetellWebhook($payload, $signature, $apiKey, $logFile)) // Invalid signature, reject the request
{
http_response_code(403); // Forbidden
$result = ['error' => 'Invalid webhook signature'];
echo json_encode($result);
exit;
}brooklyn88ua
03/11/2025, 12:10 AMNeal L.
05/13/2025, 12:03 AM