Skip to main content

construct_webhook_event

Function construct_webhook_event 

Source
pub fn construct_webhook_event(
    body: impl AsRef<[u8]>,
    headers: &HeaderMap,
    secret: &str,
) -> Result<WebhookEventPayload>
Expand description

Verifies a delivery’s signature and freshness from its headers, then parses it.

Pass the raw request body exactly as received and the request headers, e.g. axum’s axum::body::Bytes and http::HeaderMap; headers are read as verify_webhook_headers reads them. A missing, wrong or stale signature returns sdk/invalid-webhook-signature (answer 401); a body that is not a delivery returns sdk/invalid-webhook-payload (answer 400).