Handle Stripe webhook events
POST
https://app.speybooks.com/api/v1/stripe-webhook/stripeReceive and process Stripe webhook events. The processing flow is:
- Extract
Stripe-Signatureheader — reject 400 if missing - Verify signature against
STRIPE_WEBHOOK_SECRETusing the raw (unparsed) request body - Insert event into
webhook_eventsaspending - Dispatch to the appropriate handler by event type
- Update event status to
processedorfailed - Return
{ received: true }regardless of processing outcome
This endpoint must receive the raw request body (not parsed JSON) for signature verification. It is registered before Fastify's JSON content-type parser.
Error responses:
400 { error: "Missing signature" }— noStripe-Signatureheader orSTRIPE_WEBHOOK_SECRETnot configured400 { error: "Webhook Error: ..." }— signature verification failed (wrong secret, tampered payload, or replay attack)
Monitoring: Failed events can be queried from webhook_events where status = 'failed'. The error_details column contains the handler error message. The Stripe dashboard's webhook event log can be cross-referenced using the event_id column.
Response
200 Webhook received and processed. Always returns 200 to prevent Stripe retries, even if processing fails internally.
Show response fields
received booleanAlways true when the webhook is acknowledged.
Error codes
400 Missing Stripe signature header or webhook signature verification failed.