Skip to content
Mermaid templates

Webhook verification and replay protection

Includes raw-body signature validation, replay controls and durable acceptance before acknowledgement. Original worked design example; adapt responsibilities, thresholds and assumptions to your system.

Template previewMermaid
Rendering…

What this template contains

Diagram type
Sequence diagram
Source
30 lines

Make it your own.

sequenceDiagram
participant P as Provider
participant G as Webhook gateway
participant D as Transactional inbox
participant R as Outbox relay
participant Q as Work queue
participant W as Worker
P->>G: Signed payload, timestamp, delivery ID
G->>G: Verify raw-body signature and timestamp window
alt Invalid signature or expired window
 G-->>P: Reject delivery
else Valid delivery
 G->>D: Atomically insert inbox and pending outbox by delivery ID
 alt Transaction failed
  D-->>G: Not accepted
  G-->>P: Retryable error
 else Durable transaction committed or duplicate
  D-->>G: Stored delivery ID
  G-->>P: Acknowledge durable receipt
 end
end
loop Until pending outbox published
 R->>D: Read pending outbox record
 R->>Q: Publish stable delivery ID
 Q-->>R: Durable acknowledgement
 R->>D: Mark published
end
Q->>W: Deliver job, possibly repeated
W->>W: Apply effect and record delivery ID atomically
W-->>Q: Acknowledge completed or duplicate job