parseWebhookEvent function handles verification and deserialization in one call.
Import
Verify and parse a delivery
parseWebhookEvent throws if the signature does not match or if required headers are missing.
Required headers
AgentRail sends all of the following headers with every delivery. Pass them exactly as received — do not normalize or rename them.Use the raw request body
In Express, read the raw body by configuringexpress.raw:
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)