Typed Webhook Events
Spree publishes about 110 webhook events, but nothing declares them. Event names are string literals spread across models, workflows and controllers; the dashboard keeps its own hand-copied list that already drifts from the server; and @spree/sdk/webhooks types every payload as unknown. This plan declares every event once in Ruby — its name and the serializer that builds its payload — and generates everything else from that declaration: a typed event map and a verified constructWebhookEvent in @spree/sdk/webhooks, Zod schemas for runtime checks, and an Admin API endpoint the dashboard reads its event picker from.
Status: Draft — design finalized 2026-09-29, nothing built.
Depends on: Admin API (webhook endpoints are Admin API resources); Zod schemas for every SDK (shipped in #14763).
Key decisions: payloads stay on Store API serializers; back-office data is fetched from the Admin API by ID; events are declared on the model whose record is the payload; undeclared events raise in development and test and warn in production.
Steps
- Add the event catalog and the
publishes_events/publishes_eventdeclarations; lifecycle events register themselves. Warn on undeclared names. - Declare every core event; replace hand-built payload hashes with event serializers; replace the credential event list with the catalog's flag.
- Raise on undeclared names in development and test.
- Generate the event types and Zod schemas; add
constructWebhookEvent; extend the CI drift check. - Add
GET /api/v3/admin/webhook_eventsand move the dashboard picker onto it. - Document the event reference from the catalog.
Plan: https://github.com/spree/spree/blob/main/docs/plans/6.0-typed-webhook-events.md
Tracked in Linear as V-3728
Source: spree/spree