parse_webhook_event function handles verification and deserialization in one call.
Import
Verify and parse a delivery
parse_webhook_event raises an exception if the signature does not match or if the body cannot be deserialized.
Parameters
Use the raw request body
In FastAPI, read the raw body withRequest.body():
request.body before any JSON parsing middleware runs.
Set the webhook secret
Your webhook secret (AGENTRAIL_WEBHOOK_SECRET) is separate from your API key. You set it when you create a webhook subscription — see POST /event-subscriptions for the secret parameter..png?fit=max&auto=format&n=TNCV8lxzL1ij3U4N&q=85&s=7345b71aa1c450c74f35b67c2655fc43)