GitHub Issue: Implement Creative Approval Webhook System
Repository: activation-api Labels: enhancement, webhooks, creative-sync, integrationTitle
Implement bidirectional webhook system for creative approval notificationsProblem Statement
When syncing creatives to sales agents (e.g., Wonderstruck), the approval process is asynchronous and potentially manual. Currently, we successfully sync creatives withstatus: "pending"
, but we have no automated way to know when they’re approved or rejected.
Current flow:
- ✅ Sync creative to sales agent → returns
status: "pending"
- ❌ Wait for manual review (could take minutes, hours, or days)
- ❌ No notification when status changes
- ❌ Must manually poll to check status
Proposed Solution
Implement a bidirectional webhook system:1. Inbound Webhooks (Sales Agent → Us)
Sales agents POST status updates to our endpoint when creatives are approved/rejected.2. Outbound Webhooks (Us → Customer)
We forward these notifications to customer-configured webhook endpoints.3. Polling Fallback
For sales agents that don’t support webhooks, implement periodic polling.Architecture Overview
- We sync creative to sales agent, register webhook callback
- Sales agent reviews creative (manual process)
- Sales agent POSTs status to our webhook endpoint
- We create internal notification
- We POST notification to customer’s webhook URL
Implementation Tasks
Phase 1: Inbound Webhook Receiver (High Priority)
Goal: Accept status updates from sales agents- Create Express route:
POST /webhooks/creative-status/:customerId/:creativeId
- Implement HMAC signature verification for security
- Update
creative_sync_status
table on status changes - Create internal
Notification
records with types:CREATIVE_APPROVED
CREATIVE_REJECTED
CREATIVE_CHANGES_REQUESTED
- Add rate limiting and IP validation
- Add audit logging to
webhook_deliveries
table - Write unit tests for webhook receiver
- Write integration tests with mock sales agent callbacks
src/routes/webhooks/creative-status.ts
- Express route handlersrc/services/webhook-receiver-service.ts
- Business logicsrc/__tests__/routes/webhooks/creative-status.test.ts
- Tests
Phase 2: Webhook Subscription with Sales Agents
Goal: Register our callback URL when syncing creatives- Update
ADCPCreativeSyncService
to register webhook during sync - Add
webhook_url
parameter to sync requests (if ADCP supports it) - Store webhook registration details in
creative_sync_status
table - Add fields:
webhook_registered
,webhook_url
,webhook_secret
- Generate unique webhook secrets per sales agent
- Handle webhook registration failures gracefully
src/services/adcp-creative-sync-service.ts
- Add webhook registrationsrc/types/creative.ts
- Add webhook fields to sync status
Phase 3: Customer Webhook Delivery
Goal: Forward notifications to customer endpoints- Implement webhook delivery service with retries
- Add HMAC signature generation for customer webhooks
- Implement retry policy with exponential backoff
- Auto-pause webhooks after consecutive failures
- Add webhook health tracking
- Create webhook delivery audit log
- Write tests for delivery service
src/services/webhook-delivery-service.ts
- Delivery logicsrc/__tests__/services/webhook-delivery-service.test.ts
- Tests
Phase 4: Polling Fallback
Goal: Support sales agents without webhook capability- Implement periodic polling job (cron every 5 minutes)
- Add
get_creative_status
or equivalent tool call - Track which sales agents support webhooks vs polling
- Update status and create notifications on detected changes
- Add configuration to enable/disable per sales agent
src/jobs/creative-status-poller.ts
- Polling jobsrc/services/creative-status-polling-service.ts
- Polling logic
Phase 5: Monitoring & Reliability
Goal: Production-ready webhook system- 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
- Add alerting for webhook delivery failures
- Document webhook setup for customers
Database Schema Updates
Extend creative_sync_status
table
Create webhook_deliveries
table (if not exists)
API Design
Inbound Webhook Endpoint
Outbound Webhook to Customer
Security Considerations
Inbound (Sales Agent → Us)
-
HMAC Signature Verification
- Rate Limiting: Max 100 requests per minute per IP
- IP Allowlisting: Optionally restrict to known sales agent IPs
- Audit Logging: Log all webhook deliveries for forensics
Outbound (Us → Customer)
- HMAC Signature Generation
- Encrypted Credentials: Store customer auth tokens encrypted in BigQuery
- Secret Rotation: Provide endpoint for customers to rotate secrets
- Retry Limits: Auto-pause after 3 consecutive failures
Testing Strategy
Unit Tests
- HMAC signature verification
- Webhook payload validation
- Retry logic
- Status update handling
Integration Tests
- End-to-end creative sync → approval → notification flow
- Webhook delivery with retries and failures
- Polling fallback behavior
Manual Testing
- Sync creative to Wonderstruck
- Manually trigger webhook callback (simulate approval)
- Verify notification created
- Verify customer webhook called
- Test failure scenarios (invalid signature, network errors)
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%
Documentation Needed
- Customer-facing webhook setup guide
- Webhook event types reference
- Troubleshooting guide for webhook failures
- Security best practices
- Example webhook handlers (Node.js, Python, Ruby)
Related Documentation
- Detailed architecture:
docs/creative-approval-webhooks.md
- Notification types:
src/types/notifications.ts
- Existing webhook types:
src/types/webhooks.ts
Dependencies
- ✅ Creative sync working with auth (@adcp/client 0.2.4)
- ✅ Real GCS asset hosting
- ✅ Wonderstruck MCP integration
- ⏳ ADCP webhook specification (need to verify if sync_creatives supports webhook_url param)
Open Questions
-
Does ADCP spec support webhook registration in sync_creatives?
- Need to check if we can pass
webhook_url
parameter - Alternative: Separate
subscribe_creative_updates
tool call
- Need to check if we can pass
-
What’s Wonderstruck’s webhook format?
- Need to coordinate with Wonderstruck team on payload format
- Need webhook secret sharing mechanism
-
Polling frequency?
- Start with 5 minutes, optimize based on actual approval times
- Consider exponential backoff for long-pending creatives
Implementation Timeline
- Week 1: Phase 1 (Inbound webhook receiver)
- Week 2: Phase 2 (Sales agent subscription) + Phase 3 (Customer delivery)
- Week 3: Phase 4 (Polling fallback) + Testing
- Week 4: Phase 5 (Monitoring) + Documentation + Beta rollout
Risk Mitigation
- Sales agent compatibility: Start with polling fallback, add webhooks incrementally
- Customer adoption: Provide both webhooks and polling/list endpoints
- Scaling: Rate limit inbound webhooks, queue outbound deliveries
- Reliability: Comprehensive retry logic and auto-pause on failures
Instructions for GitHub
- Copy this to a new GitHub issue in the activation-api repository
- Add labels:
enhancement
,webhooks
,creative-sync
,integration
,good-first-issue
(for Phase 1 tasks) - Link to related issues/PRs:
- PR that fixed @adcp/client auth (if separate repo)
- Any existing webhook implementation PRs
- Assign to appropriate milestone
- Tag relevant team members for review