# Webhook System

## Overview
Webhook delivery system with event subscriptions, HMAC signature verification via `{{signature_header}}`, retry logic (max {{max_retries}} attempts), and {{timeout_seconds}}s per request timeout.

## Acceptance Criteria

### AC-1: Subscription Management
- Allow consumers to register webhook endpoints with target URL and event types
- Validate that the target URL is reachable via a test ping on registration
- Store subscriptions with status (active, paused, failed)

### AC-2: Event Delivery
- Deliver event payloads via HTTP POST to registered endpoints
- Include `{{signature_header}}` HMAC-SHA256 signature in each request
- Set request timeout to {{timeout_seconds}} seconds per attempt

### AC-3: Retry Logic
- Retry failed deliveries up to {{max_retries}} times
- Use exponential backoff: 1min, 5min, 30min between retries
- Mark subscription as `failed` after exhausting all retries

### AC-4: Signature Verification (Consumer Guide)
- Compute HMAC-SHA256 of the raw request body using the shared secret
- Compare computed signature with the value in `{{signature_header}}`
- Reject requests with invalid or missing signatures

### AC-5: Delivery Log
- Store delivery attempts: endpoint, event type, response code, latency, attempt number
- Expose delivery history per subscription via admin API
- Purge logs older than 30 days automatically

## Technical Notes
- Use a unique shared secret per subscription — never reuse across consumers
- Process delivery queue asynchronously to avoid blocking event producers
- Validate registered URLs against an allowlist to prevent SSRF attacks
