Creative Approval Webhook Architecture
Problem Statement
Creative sync to sales agents (e.g., Wonderstruck) is asynchronous:- Push creative →
sync_creatives
returns immediately withpending_approval
status - Manual review → Sales agent reviews creative (could take minutes, hours, or days)
- Status change → Creative approved, rejected, or changes requested
- Customer notification → How do we notify our customer of the status change?
creative_get
repeatedly to check status, which is inefficient and delays response to rejections.
Architecture Overview
Two-Way Webhook Flow
- Customer calls
sync_creatives
with their webhook URL - We sync creative to sales agent, register webhook callback
- Sales agent reviews and approves/rejects
- Sales agent POSTs status to our webhook receiver
- We create internal notification
- We POST notification to customer’s webhook URL
Implementation Components
1. Outbound: Register Webhook with Sales Agent
When callingsync_creatives
, include webhook registration:
2. Inbound: Receive Status Updates from Sales Agents
Endpoint:POST /webhooks/creative-status/:customerId/:creativeId
- Verify HMAC signature using shared secret
- Rate limit by IP and customer ID
- Log all webhook deliveries for audit
- Verify HMAC signature
- Look up creative in
creative_sync_status
table - Update sync status and approval status
- Create
Notification
with typeCREATIVE_APPROVED/REJECTED/CHANGES_REQUESTED
- Trigger customer webhook deliveries
3. Customer Webhook Subscriptions
Customers register their webhook endpoints to receive our notifications:Database Schema Updates
creative_sync_status Table
webhook_subscriptions Table (Already exists in types)
webhook_deliveries Table (Audit log)
Implementation Tasks
Phase 1: Inbound Webhook Receiver (High Priority)
- Design webhook architecture
- Create Express route:
POST /webhooks/creative-status/:customerId/:creativeId
- Implement HMAC signature verification
- Update
creative_sync_status
on status changes - Create internal
Notification
records - Add rate limiting and IP validation
- Add audit logging to
webhook_deliveries
Phase 2: Customer Webhook Subscriptions
- Create
webhook_subscribe
MCP tool - Create
webhook_list
MCP tool - Create
webhook_unsubscribe
MCP tool - Create
webhook_test
MCP tool (send test notification) - Implement webhook delivery service with retries
- Add HMAC signature generation for customer webhooks
Phase 3: Sales Agent Integration
- Check if ADCP spec supports webhook registration
- Update
sync_creatives
to register webhooks with sales agents - Implement polling fallback for agents without webhook support
- Add
get_creative_status
polling job (cron every 5 minutes)
Phase 4: Monitoring & Reliability
- Add webhook delivery metrics (success rate, latency)
- Implement auto-pause for repeatedly failing webhooks
- Add customer notification preferences (email fallback)
- Create admin dashboard for webhook health
Security Considerations
HMAC Signature Verification
Outgoing to customers
Secrets Management
- Store webhook secrets encrypted in BigQuery
- Use Google Cloud Secret Manager for encryption keys
- Rotate secrets periodically (monthly)
- Provide secret rotation endpoint for customers
Alternatives Considered
1. Polling Only (No Webhooks)
Pros: Simpler implementation, no webhook receiver needed Cons: Higher latency, more API calls, customers must implement polling2. Server-Sent Events (SSE)
Pros: Real-time updates, no customer webhook setup Cons: Requires persistent connections, complex state management3. WebSockets
Pros: Bidirectional, real-time Cons: Overkill for infrequent status updates, complex infrastructure Decision: Webhooks + polling fallback provides best balance of simplicity, reliability, and real-time updates.Testing Strategy
Unit Tests
- HMAC signature verification
- Webhook payload validation
- Retry logic
Integration Tests
- End-to-end creative sync → approval → notification flow
- Webhook delivery with retries and failures
- Customer webhook subscription CRUD
Load Tests
- 1000 concurrent webhook deliveries
- Sales agent webhook receiver under load
Rollout Plan
Week 1: Inbound Receiver
- Build and deploy webhook receiver
- Test with Wonderstruck sales agent
- Document webhook format for sales agents
Week 2: Customer Subscriptions
- Implement subscription MCP tools
- Add webhook delivery service
- Beta test with 3 customers
Week 3: Sales Agent Integration
- Update sync_creatives with webhook registration
- Implement polling fallback
- Monitor webhook delivery success rates
Week 4: Production Rollout
- Enable for all customers
- Monitor and tune retry policies
- Add customer-facing documentation
Success Metrics
- Latency: Time from approval → customer notification < 5 seconds
- Reliability: Webhook delivery success rate > 99%
- Adoption: 80% of customers using webhooks within 3 months
- Cost: Reduced polling API calls by 90%