https://retellai.com/?utm_source=discord&utm_medium=seo logo
Verify Webhook
# ❓・bug-report
f
How can I verify a webhook call from Retell without using the SDK?
s
hi @frustratedphoton
Could you please let me know what exactly you’re looking for, so I can guide you properly
f
@shahretell we use custom software and applications utilizing .NET Core and developed a Webhook to store the call_analyed event. The issue is that I can't find a way to secure the webhook without implementing your SDK (Node.js or Python) when our application is c#. I was hoping to avoid a pass-through authentication using your SDK and another application and make a call to your system to verify utilizing x-retell-signature header and our API Key. Does that make sense?
@shahretell for additional clarification, is there a RESTful way to validate the Webhook call from Retell using the x-retell-signature header and our API Key?
d
Did you ever get an answer?
I am running a test. I pulled the API key with the webhook label. I hard coded it into my code to test, and still cannot authorize. Can you please provide some guidance? import crypto from "crypto"; export default defineComponent({ async run({ steps, $ }) { // --- HARDCODED TEST --- // Paste the key you copied from the Retell dashboard directly here. const RETELL_SIGNING_SECRET = "retell_api_key_added_here"; // --- END HARDCODED TEST --- const signatureHeader = steps.trigger.event.headers["x-retell-signature"]; const requestBodyString = steps.trigger.event.raw_body; try { const [timestamp, receivedSignature] = signatureHeader.split(',').map(part => part.split('=')[1]); const payload = `${timestamp}.${requestBodyString}`; const expectedSignature = crypto.createHmac('sha256', RETELL_SIGNING_SECRET).update(payload).digest('hex'); console.log("--- SIGNATURE DEBUG ---"); console.log("Received Signature:", receivedSignature); console.log("Calculated Signature:", expectedSignature); console.log("Match?", receivedSignature === expectedSignature); console.log("--- END SIGNATURE DEBUG ---"); if (receivedSignature !== expectedSignature) { await $.respond({ status: 401, body: { error: "Unauthorized - Signatures do not match." } }); return; } console.log("Signature verification successful!"); await $.respond({ status: 200, body: { message: "Security check passed!" } }); return; } catch (e) { await $.respond({ status: 400, body: { error: "Bad request - Could not parse signature header." } }); return; } }, });
----- logs ------ 2025-07-30 03:52:05.446 call_aba52d23b922d365ebdbec86fb4 info: Starting call: call_aba52d23b922d365ebdbec86fb4 2025-07-30 03:52:06.051 call_aba52d23b922d365ebdbec86fb4 info: Ending call: call_aba52d23b922d365ebdbec86fb4 2025-07-30 03:52:06.147 call_aba52d23b922d365ebdbec86fb4 info: Webhook triggered for call_ended 2025-07-30 03:52:06.148 call_aba52d23b922d365ebdbec86fb4 info: Webhook triggered for call_analyzed 2025-07-30 03:52:09.653 call_aba52d23b922d365ebdbec86fb4 error: Error triggering webhook for call_analyzed Axios Error: error code: ERR_BAD_REQUEST, error message: Request failed with status code 401 response status: 401 response data: [{"error":"1"},"Unauthorized"] 2025-07-30 03:52:11.910 call_aba52d23b922d365ebdbec86fb4 error: Error triggering webhook for call_ended Axios Error: error code: ERR_BAD_REQUEST, error message: Request failed with status code 401 response status: 401 response data: [{"error":"1"},"Unauthorized"]
@shahretell not sure if you're able to help me with this one as well
@Omar Ashraf | Community Lead sorry, saw you were online, trying to get this going.
This is what i used to test: This is the bare bones authentication code test: import crypto from "crypto"; export default defineComponent({ async run({ steps, $ }) { console.log("--- STARTING BARE-BONES SECURITY TEST (JSON.stringify method) ---"); // --- Retell Signature Verification --- const RETELL_SIGNING_SECRET = process.env.RETELL_SIGNING_SECRET; if (!RETELL_SIGNING_SECRET) { console.error("CRITICAL: RETELL_SIGNING_SECRET environment variable is not set."); await $.respond({ status: 500, body: { error: "Server configuration error: RETELL_SIGNING_SECRET is not set." } }); return; } const signatureHeader = steps.trigger.event.headers["x-retell-signature"]; // Use the parsed body and re-stringify it to match Retell's documented method. const requestBodyString = JSON.stringify(steps.trigger.event.body); // Check if the header exists before trying to parse it if (!signatureHeader) { console.error("Unauthorized: Missing x-retell-signature header."); await $.respond({ status: 401, body: { error: "Unauthorized: Missing signature header." } }); return; } try { const [timestamp, receivedSignature] = signatureHeader.split(',').map(part => part.split('=')[1]); const payload = `${timestamp}.${requestBodyString}`; const expectedSignature = crypto.createHmac('sha256', RETELL_SIGNING_SECRET).update(payload).digest('hex');
// --- DEBUGGING LOGS --- console.log("--- SIGNATURE DEBUG ---"); console.log("Timestamp from header:", timestamp); console.log("Received Signature from header:", receivedSignature); console.log("Calculated Signature (what we expect):", expectedSignature); console.log("Does received signature match calculated signature?", receivedSignature === expectedSignature); console.log("--- END SIGNATURE DEBUG ---"); if (receivedSignature !== expectedSignature) { console.error("Unauthorized: Invalid signature. The calculated signature did not match the one received from Retell."); await $.respond({ status: 401, body: { error: "Unauthorized: Invalid signature." } }); return; } // If we reach this point, the signature is valid! console.log("✅ Signature verification successful!"); // Send a success response back in the format Retell expects await $.respond({ status: 200, headers: { "Content-Type": "application/json" }, body: { call_inbound: { dynamic_variables: { security_check_status: "passed" } } } }); return; } catch (e) { console.error("Error during signature verification:", e.message); await $.respond({ status: 400, body: { error: "Bad request: Could not parse signature header." } }); return; } }, });