edwardsalfred
10/03/2025, 3:30 PMAI Evy
10/03/2025, 3:30 PMAI Evy
10/03/2025, 3:30 PMX-Retell-Signature header [(1) ]() [(2) ]() . Here are the most common causes and solutions for signature validation failures:
1. Use the correct API key
Make sure you're using the designated webhook API key (not just any API key) in your Retell.verify() function [(3) ]() .
2. Correct JSON serialization
The most common cause is incorrect JSON serialization . Make sure you're using:
For Python:
python
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from retell import Retell
retell = Retell(api_key=os.environ["RETELL_API_KEY"])
@app.post("/check-weather")
async def check-weather(request: Request) :
try:
post_data = await request.json()
valid_signature = retell.verify(
json.dumps(post_data, separators=(",", ":") , ensure_ascii=False) ,
api_key=str(os.environ["RETELL_API_KEY"]) ,
signature=str(request.headers.get("X-Retell-Signature") ) ,
)
if not valid_signature:
print(
"Received Unauthorized",
post_data["event"],
post_data["data"]["call_id"],
)
return JSONResponse(status_code=401, content={"message": "Unauthorized"})
[(2) ]()
For Node.js:edwardsalfred
10/03/2025, 4:17 PMedwardsalfred
10/03/2025, 4:18 PMAI Evy
10/03/2025, 4:18 PMAI Evy
10/03/2025, 4:19 PMpython
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from retell import Retell
retell = Retell(api_key=os.environ["RETELL_API_KEY"])
@app.post("/check-weather")
async def check-weather(request: Request) :
try:
post_data = await request.json()
valid_signature = retell.verify(
json.dumps(post_data, separators=(",", ":") , ensure_ascii=False) ,
api_key=str(os.environ["RETELL_API_KEY"]) ,
signature=str(request.headers.get("X-Retell-Signature") ) ,
)
if not valid_signature:
print(
"Received Unauthorized",
post_data["event"],
post_data["data"]["call_id"],
)
return JSONResponse(status_code=401, content={"message": "Unauthorized"})
[(4) ]()
3. Verify your environment configuration
Ensure your environment variable RETELL_API_KEY is set to the webhook-designated API key, not just any API key. The webhook verification requires the specific key that has the webhook badge [(1) ]() .
4. Alternative security option
You can also secure your server by allowlisting Retell IP addresses: 100.20.5.228 [(1) ]() [(4) ]() .AI Evy
10/03/2025, 4:19 PMjavascript
// install the sdk: <https://docs.retellai.com/get-started/sdk>
import { Retell } from "retell-sdk";
import express, { Request, Response } from "express";
const app = express() ;
app.use(express.json() ) ;
app.post("/webhook", (req: Request, res: Response) => {
if (
!Retell.verify(
JSON.stringify(req.body) ,
process.env.RETELL_API_KEY,
req.headers["x-retell-signature"] as string,
)
) {
console.error("Invalid signature") ;
return;
}
const {event, call} = req.body;
// process the webhook
// Acknowledge the receipt of the event
res.status(204) .send() ;
}) ;
[(1) ]()
For Python:AI Evy
10/03/2025, 4:19 PMAI Evy
10/03/2025, 4:19 PM