Handle Retell Webhook
POST /api/v1/webhooks/retell
POST
/api/v1/webhooks/retell
Handle incoming Retell AI voice-call webhooks.
Processes call_analyzed events:
- Verifies HMAC-SHA256 signature via
x-retell-signatureheader. - Enforces Redis idempotency (48-hour window).
- Resolves tenant from
to_number(the agent’s DID). - Writes ContactTimeline entry (call touch with encoded metadata).
- On successful call: stores memory crystal + quality-gates follow-up.
- Emits
OUTREACH_CALL_COMPLETEDevent unconditionally. - Emits
AGENT_TASK_QUEUEDwhen call succeeded and quality gate passes, or when escalation is flagged regardless of success.
All other event types are acknowledged with 200 immediately.
Returns:
WebhookAck with received=True on success, or
status="duplicate" (still 200) when the call_id was
already processed inside the idempotency window.
Raises:
HTTPException: 500 when RETELL_API_KEY is unset — the HMAC
secret would be the empty string, whose digest anyone can
compute, so the route refuses to serve rather than verify
against a publicly known key; 403 when x-retell-signature
is missing or does not verify; 400 when the body is not valid
UTF-8 or not valid JSON; 404 when the tenant cannot be
resolved from the phone number.
Authorizations
Responses
200
Successful Response