zigzag8784
12/02/2025, 1:23 AMAI Evy
12/02/2025, 1:23 AMAI Evy
12/02/2025, 1:23 AMX-Retell-Signature header) [(1) ]()
3. Add your required Authorization header with the bearer token
4. Forward the request to your actual third-party API
5. Return the response back to Retell
The Retell custom function will send requests with these headers :
- `X-Retell-Signature`: for request verification
- Content-Type: application/json
To verify requests are from Retell, you can use this approach :AI Evy
12/02/2025, 1:23 AMpython
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"})
Your intermediary service would then add the Authorization header before calling your actual webhook endpoint.AI Evy
12/02/2025, 1:24 AMAI Evy
12/02/2025, 1:24 AMzigzag8784
12/02/2025, 1:28 AMzigzag8784
12/02/2025, 1:28 AMAI Evy
12/02/2025, 1:28 AMAI Evy
12/02/2025, 1:28 AMAuthorization
- **Header Value**: Bearer {{access_token}}
If it's still showing unauthorized, the issue might be:
1. The dynamic variable {{access_token}} isn't properly set - Make sure you've defined this variable and it contains a valid token
2. The token format - Verify the token value itself is correct (no extra spaces, proper encoding)
3. Token expiration - Check if your bearer token has expired
The custom function feature supports setting custom headers, so you shouldn't need an intermediary layer just for authentication. The direct approach should work once the token variable is properly configured.AI Evy
12/02/2025, 1:29 AMAI Evy
12/02/2025, 1:29 AM