APEX WEBHOOK RELIABILITY

What this is: Webhook contract: HMAC signatures, dedupe, DLQ, retry windows - what consumers must verify.

How it works

Webhooks carry an HMAC signature over the payload; consumers must verify before acting. Delivery is at-least-once with dedupe on the event id, retries on a schedule, and a dead-letter queue after the window.

Development guide

Code map

Public surface

HTTP endpoints

Schema owned

Depends on

outbox_events · webhook_deliveries · webhook_subscriptions

Tests

Step-by-step: extending this subsystem

  1. Schema - add a numbered file in schema/ if new tables are needed; never edit an applied migration.
  2. Service - implement logic in apex/webhooks/service.py inside a conn.transaction() block; post financial effects through apex/ledger/, never direct balance math.
  3. Route - expose it in apex/api/ (or the module's router) with scope checks via the existing auth dependency.
  4. Events - emit outbox events for anything a consumer/webhook needs to observe.
  5. Test - add cases in tests/ near the files listed above; run .venv/bin/python -m pytest -k webhooks.
  6. Invariants - money stays integer minor units; ledger writes stay balanced; sandbox stays behind APEX_ENV gating.

Classification: see below. Inspected against the live codebase in forensic cycle 1.

UPDATED (2026-11-04): IMPLEMENTED - see apex/webhooks/service.py

(subscriptions, HMAC sign/verify with timestamp tolerance, fanout_pending

delivery, dead-letter replay gating - A8-14). Original Phase-1 finding

follows: NOT IMPLEMENTED - no webhook subsystem; payment_events table

provides the event stream source.

See APEX_SYSTEM_INVENTORY.md and APEX_DEFECT_REGISTER.md for the full picture.