Webhook System Routes
1. Purpose & Context (The âWhyâ)
-
Goal: Enable developers to configure custom webhooks for real-time event notifications from PenguinMails.
-
Feature References:
-
User Journey: Set up once during integration, monitor regularly for delivery health.
2. UI Patterns & Components (The âHowâ)
-
Core Components:
-
WebhookCard: Display webhook with status, events, and quick actions. -
EventSelector: Multi-select checkbox tree for event subscriptions. -
WebhookTester: Send test events and view responses. -
DeliveryLog: Real-time webhook delivery log with filtering. -
SignatureVerifier: Code generator for signature verification. -
EventReplay: Time-range selector for replaying historical events.
-
-
Analytics Patterns: Delivery success rate, response times, error analysis.
-
Layout: Settings Layout with sidebar navigation.
3. Route Specifications
| Route | Access | Purpose | State/Data Requirements |
|---|---|---|---|
/dashboard/settings/webhooks | Admin, Developer | Webhook Overview | List of webhooks, quick stats, create button. |
/dashboard/settings/webhooks/create | Admin, Developer | Create Webhook | Form: Name, URL, Events, Filters. |
/dashboard/settings/webhooks/:id | Admin, Developer | Webhook Details | Configuration, delivery log, test interface. |
/dashboard/settings/webhooks/:id/edit | Admin, Developer | Edit Webhook | Update configuration and event subscriptions. |
/dashboard/settings/webhooks/:id/deliveries | Admin, Developer | Delivery Log | Detailed delivery history with filtering. |
/dashboard/settings/webhooks/:id/test | Admin, Developer | Test Webhook | Send test events, view request/response. |
/dashboard/settings/webhooks/events | Admin, Developer | Event Reference | Documentation of all available events. |
4. Detailed View Descriptions
/dashboard/settings/webhooks - Webhook Overview
User Story: âAs a developer, I want to see all configured webhooks and their health status, so I can quickly identify and fix issues.â
What Youâll Find:
Overview Stats
Metrics Cards (Top Row):
-
Active Webhooks: â3â
-
Events Delivered Today: â12,345â
-
Success Rate: â99.2%â
-
Failing Webhooks: â0â (Red if > 0)
Webhook List
Webhook Cards (Grid or List View):
Each card displays:
Webhook Name: âCRM Contact Syncâ
-
Endpoint:
https://yourapp.com/webhooks/penguinmails -
Status Badge:
-
Active (Green): Receiving events successfully.
-
Paused (Gray): Manually disabled.
-
Failing (Red): Recent delivery failures.
-
Inactive (Gray): Auto-paused after 100 failures.
-
Event Subscriptions:
-
âSubscribed to 7 events: email.opened, email.clicked, âŚâ
-
âView Allâ Link: Expands full event list.
Health Indicators:
-
Success Rate: â99.2%â (Last 24 hours)
-
Last Delivery: â2 minutes agoâ
-
Failed Deliveries: â3 in last 24 hoursâ
Quick Actions:
-
Test button: Send test event.
-
Pause/Resume toggle.
-
View Details link.
-
Delete button (with confirmation).
â+ Create Webhookâ Button: Navigate to webhook creation.
Quick Filters
Filter Bar:
-
Status: All, Active, Paused, Failing.
-
Events: Filter by subscribed event types.
-
Search: Search by name or endpoint URL.
ESP Webhooks Notice
Info Banner:
âLooking for ESP webhooks (Postmark, Mailgun)? Configure ESP webhooks ââ
User Journey Context: Regular monitoring (daily/weekly) to ensure webhook health.
Related Documentation:
/dashboard/settings/webhooks/create - Create Webhook
User Story: âAs a developer, I want to create a webhook to receive real-time notifications, so I can integrate PenguinMails with my application.â
What Youâll Find:
Webhook Creation Form
Step 1: Basic Configuration
Webhook Name:
-
Input Field: Text input (e.g., âCRM Contact Syncâ).
-
Help Text: âChoose a descriptive name to identify this webhook.â
Description (Optional):
- Textarea: Additional notes about webhook purpose.
Endpoint URL:
-
Input Field: URL input (e.g.,
https://yourapp.com/webhooks/penguinmails). -
Validation: Must be HTTPS (HTTP allowed for localhost testing).
-
Help Text: âYour server endpoint that will receive webhook events.â
Status:
-
Radio Buttons:
-
â Active (Start receiving events immediately)
-
â Paused (Create but donât send events yet)
-
Step 2: Event Selection
Event Categories (Expandable Sections):
Email Events:
-
â email.sent - Email queued for sending
-
â email.delivered - Email successfully delivered
-
â email.opened - Recipient opened email
-
â email.clicked - Recipient clicked link
-
â email.bounced - Email bounced (hard or soft)
-
â email.spam_reported - Marked as spam
-
â email.unsubscribed - Recipient unsubscribed
Campaign Events:
-
â campaign.launched - Campaign started sending
-
â campaign.completed - Campaign finished
-
â campaign.paused - Campaign paused by user
Contact Events:
-
â contact.created - New contact added
-
â contact.updated - Contact information updated
-
â contact.unsubscribed - Contact unsubscribed from all
Quick Select Buttons:
-
âSelect Allâ: Check all events.
-
âEmail Events Onlyâ: Select all email events.
-
âClear Allâ: Uncheck all events.
Event Preview:
âYouâve selected 5 events. View sample payloads ââ
Step 3: Event Filters (Optional)
Advanced Filtering Section (Expandable):
Filter by Workspace:
-
Dropdown: Select specific workspaces (default: All).
-
Multi-select: Choose multiple workspaces.
Filter by Campaign:
-
Dropdown: Select specific campaigns (default: All).
-
Help Text: âOnly receive events from selected campaigns.â
Filter by Contact Tags:
-
Tag Input: Enter tags (e.g., âvipâ, âpremiumâ).
-
Help Text: âOnly receive events for contacts with these tags.â
Custom JSON Filters (Advanced):
{
"contact.tags": ["vip", "premium"],
"campaign.type": "promotional",
"email.opened_count": { "$gte": 3 }
}
âTest Filterâ Button: Validate filter syntax.
Step 4: Security & Retry Configuration
Signature Verification:
-
Auto-generated Secret:
whsec_abc123...(shown after creation). -
Help Text: âUse this secret to verify webhook signatures.â
Retry Configuration:
-
Enable Retries: Toggle (default: On).
-
Max Retry Attempts: Number input (1-10, default: 5).
-
Retry Delays: â1m, 5m, 15m, 1h, 24hâ (exponential backoff).
Timeout:
-
Response Timeout: Number input (1-30 seconds, default: 5).
-
Help Text: âWebhook must respond within this time.â
IP Whitelist (Optional):
-
Webhook Source IPs: Display PenguinMails IP ranges.
-
Copy Button: Copy IP list for firewall configuration.
Step 5: Test Before Saving
Test Webhook Section:
-
âSend Test Eventâ Button: Sends sample event to endpoint.
-
Event Type: Dropdown (select which event to test).
-
Use Sample Data: Checkbox (default: On).
Test Result Display:
Sending test event to https://yourapp.com/webhooks...
âĹâ Test successful!
Status: 200 OK
Response Time: 142ms
Response Body: "OK"
Or Error:
âĹâ Test failed
Status: 500 Internal Server Error
Error: Connection timeout
[Retry Test] [Save Anyway]
âCreate Webhookâ Button: Saves webhook configuration.
Webhook Created Success
Success Modal:
-
Title: âWebhook Created Successfullyâ
-
Webhook ID:
wh_abc123 -
Secret Key:
whsec_def456...(shown once) -
Warning: ââť ï¸ Save this secret key. You wonât be able to see it again.â
Copy Buttons:
-
Copy Webhook ID
-
Copy Secret Key
Next Steps:
User Journey Context: One-time setup per integration, occasional updates for new event types.
Related Documentation:
Technical Integration:
-
Secret Generation: Cryptographically secure random string.
-
Signature: HMAC-SHA256 with secret key.
-
Storage: Secret hashed before storing in database.
/dashboard/settings/webhooks/:id - Webhook Details
User Story: âAs a developer, I want to view webhook configuration and delivery history, so I can monitor and troubleshoot my integration.â
What Youâll Find:
Webhook Header
Webhook Name: âCRM Contact Syncâ
-
Status Badge: Active (Green) or Failing (Red).
-
Actions: Edit, Test, Pause/Resume, Delete.
Endpoint: https://yourapp.com/webhooks/penguinmails
- Copy Button: Copy URL to clipboard.
Created: âNovember 1, 2025 by john@company.comâ
Configuration Summary
Event Subscriptions (Expandable):
-
email.sent
-
email.delivered
-
email.opened
-
email.clicked
-
email.bounced
âEdit Eventsâ Link: Navigate to edit page.
Event Filters (if configured):
{
"workspaces": ["Client A", "Client B"],
"contact.tags": ["vip"]
}
âEdit Filtersâ Link: Navigate to edit page.
Security Settings:
-
Secret Key:
whsec_...xyz(masked, âShowâ toggle requires re-auth). -
âRotate Secretâ Button: Generate new secret, revoke old one.
-
Retry Attempts: â5 attempts with exponential backoffâ
-
Timeout: â5 secondsâ
Health & Performance
Delivery Stats (Last 24 Hours):
-
Total Deliveries: â1,234â
-
Successful: â1,223 (99.1%)â
-
Failed: â11 (0.9%)â
-
Average Response Time: â145msâ
Success Rate Chart (Line Chart):
-
Shows success rate over time (last 7 days).
-
Y-Axis: Success percentage (0-100%).
-
X-Axis: Time.
Response Time Chart (Line Chart):
-
Shows average response time over time.
-
Warning Line: 1000ms (yellow).
-
Critical Line: 3000ms (red).
Recent Deliveries
Delivery Log Table (Last 50):
| Timestamp | Event Type | Status | Response Time | Actions |
|---|---|---|---|---|
| 2:34 PM | email.opened | âĹâ 200 OK | 142ms | View |
| 2:33 PM | email.clicked | âĹâ 200 OK | 156ms | View |
| 2:30 PM | email.bounced | âĹâ 500 Error | 5000ms | Retry |
Filters:
-
Status: All, Success, Failed, Pending Retry.
-
Event Type: Dropdown filter.
-
Date Range: Date picker.
âView Full Logâ Link: Navigate to detailed delivery log.
Quick Actions
Test Webhook:
- âSend Test Eventâ Button: Opens test modal.
Pause Webhook:
- âPause Webhookâ Button: Stop sending events temporarily.
Rotate Secret:
- âRotate Secret Keyâ Button: Generate new secret (requires confirmation).
Delete Webhook:
- âDelete Webhookâ Button: Permanently remove webhook (requires confirmation).
User Journey Context: Regular monitoring and troubleshooting.
Related Documentation:
/dashboard/settings/webhooks/:id/deliveries - Detailed Delivery Log
User Story: âAs a developer, I want to see detailed webhook delivery logs, so I can debug integration issues.â
What Youâll Find:
Delivery Log Filters
Filter Bar:
-
Status: All, Success, Failed, Pending Retry.
-
Event Type: Multi-select dropdown.
-
Date Range: Date picker (default: Last 7 days).
-
Search: Search by event ID or contact email.
Export:
- âExport CSVâ Button: Download filtered logs.
Delivery Log Table
Detailed View:
| Timestamp | Event ID | Event Type | Status | Response Time | Attempt | Actions |
|---|---|---|---|---|---|---|
| Nov 25, 2:34 PM | evt_abc123 | email.opened | âĹâ 200 OK | 142ms | 1/1 | View |
| Nov 25, 2:33 PM | evt_def456 | email.clicked | âĹâ 200 OK | 156ms | 1/1 | View |
| Nov 25, 2:30 PM | evt_ghi789 | email.bounced | âĹâ 500 Error | 5000ms | 2/5 | Retry, View |
Expandable Rows:
Click row to expand and view:
Request Details:
POST https://yourapp.com/webhooks/penguinmails
Content-Type: application/json
X-PenguinMails-Signature: sha256=abc123...
X-PenguinMails-Event: email.opened
X-PenguinMails-Delivery-ID: del_xyz789
{
"id": "evt_abc123",
"type": "email.opened",
"created_at": "2025-11-25T14:34:00Z",
"data": {
"email_id": "msg_xyz789",
"contact": {
"email": "user@example.com"
}
}
}
Response Details:
200 OK
Content-Type: text/plain
Response Time: 142ms
OK
Actions:
-
âCopy Requestâ Button: Copy request payload.
-
âCopy Responseâ Button: Copy response body.
-
âRetry Nowâ Button: Manually retry failed delivery.
-
âView Eventâ Link: Navigate to event details.
Failed Deliveries Section
Failed Deliveries Summary:
-
Total Failed: â11 in last 24 hoursâ
-
Most Common Error: â500 Internal Server Error (7 occurrences)â
-
Retry Status: â3 pending retry, 8 exhausted retriesâ
Failed Deliveries Table:
| Timestamp | Event Type | Error | Attempts | Next Retry | Actions |
|---|---|---|---|---|---|
| 2:30 PM | email.bounced | 500 Error | 2/5 | In 3 minutes | Retry |
| 2:25 PM | email.opened | Timeout | 5/5 | Exhausted | View |
Bulk Actions:
-
âRetry All Failedâ Button: Retry all failed deliveries.
-
âClear Failed Logâ Button: Archive failed deliveries.
User Journey Context: Troubleshooting delivery issues, monitoring webhook health.
Related Documentation:
/dashboard/settings/webhooks/:id/test - Test Webhook
User Story: âAs a developer, I want to test my webhook with different event types, so I can verify my integration works correctly.â
What Youâll Find:
Test Configuration
Event Type Selector:
-
Dropdown: Select event type to test.
- Options: email.sent, email.delivered, email.opened, email.clicked, email.bounced, etc.
Data Source:
-
Radio Buttons:
-
â Use Sample Data (default)
-
â Use Real Data from Campaign/Contact
-
If âUse Real Dataâ selected:
-
Campaign: Dropdown (select campaign).
-
Contact: Dropdown (select contact).
-
Help Text: âTest event will use actual data from selected campaign/contact.â
Test Payload Preview
Payload Display (JSON):
{
"id": "evt_test_1234567890",
"type": "email.opened",
"created_at": "2025-11-25T14:30:00Z",
"data": {
"email_id": "msg_sample",
"campaign_id": "camp_sample",
"contact": {
"id": "cont_sample",
"email": "test@example.com",
"first_name": "Test",
"last_name": "User"
},
"opened_at": "2025-11-25T14:30:00Z",
"user_agent": "Mozilla/5.0...",
"ip_address": "192.168.1.1"
}
}
âEdit Payloadâ Button: Opens JSON editor for custom payload.
Send Test
âSend Test Eventâ Button: Sends test event to webhook endpoint.
Test Progress:
Sending test event to https://yourapp.com/webhooks...
âł Waiting for response...
Test Result:
Success:
âĹâ Test successful!
Request:
POST https://yourapp.com/webhooks/penguinmails
Headers: X-PenguinMails-Signature: sha256=...
Response:
Status: 200 OK
Response Time: 142ms
Body: "OK"
[View Full Request] [View Full Response]
Failure:
âĹâ Test failed
Error: Connection timeout after 5000ms
Possible causes:
- Endpoint is unreachable
- Firewall blocking requests
- Server not responding
[Retry Test] [Edit Webhook] [View Troubleshooting Guide]
Code Examples
Signature Verification Code (Tabbed):
Node.js:
const crypto = require('crypto');
function verifySignature(payload, signature, secret) {
const hmac = crypto.createHmac('sha256', secret);
hmac.update(JSON.stringify(payload));
const digest = `sha256=${hmac.digest('hex')}`;
return crypto.timingSafeEqual(
Buffer.from(digest),
Buffer.from(signature)
);
}
// Usage
app.post('/webhooks/penguinmails', (req, res) => {
const signature = req.headers['x-penguinmails-signature'];
const secret = 'whsec_...'; // Your webhook secret
if (!verifySignature(req.body, signature, secret)) {
return res.status(401).send('Invalid signature');
}
// Process event
console.log('Event:', req.body.type);
res.status(200).send('OK');
});
TypeScript/Node.js:
import crypto from 'crypto';
import express, { Request, Response } from 'express';
function verifySignature(payload: string, signature: string, secret: string): boolean {
const hmac = crypto.createHmac('sha256', secret);
hmac.update(payload, 'utf8');
const computed = hmac.digest('hex');
const expected = `sha256=${computed}`;
return crypto.timingSafeEqual(
Buffer.from(expected),
Buffer.from(signature)
);
}
// Usage
const app = express();
app.use(express.json());
app.post('/webhooks/penguinmails', (req: Request, res: Response) => {
const signature = req.headers['x-penguinmails-signature'] as string;
const secret = 'whsec_...'; // Your webhook secret
if (!verifySignature(JSON.stringify(req.body), signature, secret)) {
return res.status(401).send('Invalid signature');
}
// Process event
console.log('Event:', req.body.type);
return res.status(200).send('OK');
});
Copy Button: Copy code snippet.
User Journey Context: Initial setup and ongoing testing during development.
Related Documentation:
/dashboard/settings/webhooks/events - Event Reference
User Story: âAs a developer, I want to see all available webhook events and their payloads, so I can choose which events to subscribe to.â
What Youâll Find:
Event Categories
Sidebar Navigation:
-
Email Events (7)
-
Campaign Events (3)
-
Contact Events (3)
-
System Events (2)
Event Documentation
Example: email.opened Event
Event Type: email.opened
Description: âTriggered when a recipient opens an email. Includes location and device information.â
Frequency: âHigh - Can be triggered multiple times per emailâ
Payload Schema:
{
"id": "string (UUID)",
"type": "email.opened",
"created_at": "string (ISO 8601)",
"data": {
"email_id": "string (UUID)",
"campaign_id": "string (UUID)",
"contact": {
"id": "string (UUID)",
"email": "string",
"first_name": "string",
"last_name": "string"
},
"opened_at": "string (ISO 8601)",
"user_agent": "string",
"ip_address": "string",
"location": {
"city": "string",
"region": "string",
"country": "string"
}
}
}
Example Payload:
{
"id": "evt_abc123",
"type": "email.opened",
"created_at": "2025-11-25T14:30:00Z",
"data": {
"email_id": "msg_xyz789",
"campaign_id": "camp_def456",
"contact": {
"id": "cont_ghi012",
"email": "user@example.com",
"first_name": "Sarah",
"last_name": "Johnson"
},
"opened_at": "2025-11-25T14:30:00Z",
"user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)",
"ip_address": "192.168.1.1",
"location": {
"city": "New York",
"region": "NY",
"country": "US"
}
}
}
Copy Button: Copy example payload.
Related Events:
-
email.sent
-
email.delivered
-
email.clicked
Use Cases:
-
Update CRM with engagement data
-
Trigger follow-up workflows
-
Track email performance
Event Comparison Table
All Events Summary:
| Event Type | Frequency | Retry Safe | Typical Use Case |
|---|---|---|---|
| email.sent | High | Yes | Track sending status |
| email.delivered | High | Yes | Confirm delivery |
| email.opened | Very High | Yes | Measure engagement |
| email.clicked | High | Yes | Track link clicks |
| email.bounced | Medium | Yes | Update contact status |
| campaign.launched | Low | Yes | Trigger notifications |
| contact.created | Medium | Yes | Sync to CRM |
User Journey Context: Reference during webhook setup and development.
Related Documentation:
5. Related API Endpoints
| Route | Related API | Description |
|---|---|---|
/settings/webhooks | Webhooks API | GET /api/v1/platform/webhooks (List webhooks). |
/settings/webhooks/create | Webhooks API | POST /api/v1/platform/webhooks (Create webhook). |
/settings/webhooks/:id | Webhooks API | GET /api/v1/platform/webhooks/{id} (Get details). |
/settings/webhooks/:id/edit | Webhooks API | PUT /api/v1/platform/webhooks/{id} (Update webhook). |
/settings/webhooks/:id/test | Webhooks API | POST /api/v1/platform/webhooks/{id}/test (Send test event). |
/settings/webhooks/:id/deliveries | Webhooks API | GET /api/v1/platform/webhooks/{id}/deliveries (Delivery log). |
6. Data Strategy
-
Fetching Method:
-
Webhook List: Server Component (cached for 5 minutes).
-
Delivery Log: Client Component with real-time updates (SWR).
-
Test Results: Client Component with immediate feedback.
-
-
Caching:
-
Webhook Config: Cached for 5 minutes.
-
Delivery Stats: Cached for 1 minute.
-
Delivery Log: No caching (real-time).
-
-
Security:
-
Secret Keys: Never exposed after creation (hashed in database).
-
Signature Verification: Required on all webhook deliveries.
-
Admin Only: All webhook routes require admin or developer role.
-
7. Edge Cases & Error Handling
-
Invalid Endpoint URL: Show âEndpoint must be a valid HTTPS URL.â
-
Test Timeout: Show âEndpoint did not respond within 5 seconds. Check your server.â
-
Signature Mismatch: Log security warning, show âSignature verification failed. Check your secret key.â
-
Rate Limit Exceeded: Show âToo many webhook deliveries. Upgrade plan for higher limits.â
-
Webhook Auto-Paused: Email notification + banner: âWebhook paused after 100 consecutive failures. [View details â]â
-
Duplicate Events: Implement idempotency keys to prevent duplicate processing.
8. Component Architecture
Page Components
-
WebhookOverview(Server)- Features: Webhook list, health stats, quick actions.
-
WebhookCreator(Client)- Features: Multi-step form, event selector, test interface.
-
WebhookDetails(Server)- Features: Configuration display, delivery stats, recent log.
-
DeliveryLog(Client)- Features: Real-time log, filtering, export, retry actions.
-
WebhookTester(Client)- Features: Test event sender, payload editor, result display.
-
EventReference(Server)- Features: Event documentation, payload schemas, examples.
Shared Components
-
WebhookCard: Reused in overview and list views. -
EventSelector: Reused in create and edit forms. -
SignatureVerifier: Reused in details and test views. -
DeliveryStatus: Reused across delivery logs and stats.
9. Related Documentation
Feature Documentation
-
Webhook System - Complete webhook system guide
-
API Access - API authentication and keys
-
ESP Integration - ESP webhook configuration
Technical Documentation
-
Webhooks API Reference - API endpoints for webhook management
-
Event Reference - All available events
-
Signature Verification - Security implementation
User Journeys
-
Developer Journey - Webhook integration workflows (internal journey reference)
-
Integration Setup - Webhook setup for business users (internal journey reference)
Last Updated: November 25, 2025 Status: Planned - MVP Feature Target Release: Q1 2026
Webhook system routes provide comprehensive tools for developers to receive real-time event notifications with secure delivery, retry logic, and detailed monitoring.