POST /webhook receives these events, verifies their authenticity, and dispatches them to the appropriate handler.
How the endpoint works
When Stripe sends an event, the endpoint follows three steps:- Reads the raw request body as text (required for signature verification).
- Verifies the
stripe-signatureheader usingstripe.webhooks.constructEvent. If verification fails, the request is rejected with a400status. - Dispatches the event through a
switchstatement to the handler for that event type.
app/routes/webhook.ts
Endpoint reference
| Property | Value |
|---|---|
| Method | POST |
| Path | /webhook |
| Required header | stripe-signature |
| Success response | 200 { "data": "webhook" } |
| Error response | 400 |
Signature verification
Stripe signs every webhook payload with a secret tied to your endpoint. The app verifies this signature using:body— the raw request body as a string (not parsed JSON)stripeSignature— the value of thestripe-signaturerequest headerwebhookSecret— thewhsec_...secret from your Stripe Dashboard or CLI
Configuring the webhook
Stripe Dashboard
Open the Webhooks page
In your Stripe Dashboard, go to Developers → Webhooks and click Add endpoint.
Select events to listen for
Add the following events:
invoice.paidinvoice.payment_failedcustomer.subscription.deleted
Stripe CLI (local development)
Use the Stripe CLI to forward events to your local server during development:The signing secret generated by
stripe listen is different from the one in the Dashboard. Use the CLI secret locally and the Dashboard secret in production.