Prompt
How do I set up app-to-app workflows with webhooks
Latest observation
Setting up app-to-app workflows with webhooks usually means: your app emits events to another app via HTTP callbacks, and the receiving app processes those events to trigger automation.
Here’s a practical way to set it up.
1) Define the workflow
Start by deciding:
- Which app sends the event?
Example: “CRM app” - Which app receives it?
Example: “Billing app” - What event should trigger the webhook?
Example:invoice.paid,user.created,order.shipped - What should happen on the receiving side?
Example: create subscription, send email, update record
A good rule: webhooks are best for event-driven automation, not polling.
2) Expose a webhook endpoint in the receiving app
The receiving app needs an HTTP endpoint like:
POST /webhooks/events
It should:
- Accept
POSTrequests - Parse JSON payloads
- Return a quick
200 OKor202 Accepted - Process the event asynchronously if possible
Example payload:
{
"event": "invoice.paid",
"timestamp": "2026-10-19T12:00:00Z",
"data": {
"invoice_id": "inv_123",
"customer_id": "cus_456",
"amount": 4999
}
}
3) Secure the webhook
Webhooks should be authenticated so random callers can’t spoof events.
Common approaches:
HMAC signature
- Sender signs the payload with a shared secret
- Receiver verifies the signature
Example concept:
- Sender computes signature over raw request body
- Sends header like:
X-Signature: sha256=abc123...
Receiver recomputes and compares.
Other protections
- Use HTTPS only
- Include a timestamp to prevent replay attacks
- Validate the sender’s IP only if your platform supports stable IPs
- Use per-tenant or per-connection secrets
4) Make the endpoint idempotent
Webhooks can be delivered more than once. Your receiving app should handle duplicates safely.
Use one of these:
- A unique
event_id - Store processed event IDs
- Ignore duplicates if already processed
Example:
{
"event_id": "evt_001",
"event": "invoice.paid"
}
If evt_001 was already handled, do nothing.
5) Handle retries and failures
The sender should retry if it doesn’t receive a success response.
Typical behavior:
- Retry on timeouts
- Retry on 5xx errors
- Don’t retry on 4xx errors unless the issue is temporary
Best practices:
- Respond quickly
- Queue work internally
- Use exponential backoff for retries
- Log failed deliveries
6) Build the sender side
When the source app experiences an event, it sends the webhook:
Example with curl
curl -X POST https://receiver.example.com/webhooks/events \
-H "Content-Type: application/json" \
-H "X-Signature: sha256=..." \
-d '{
"event_id": "evt_001",
"event": "invoice.paid",
"data": {
"invoice_id": "inv_123"
}
}'
In real systems, the sender usually:
- Fetches the event
- Serializes payload
- Signs it
- Sends HTTP request
- Retries if needed
7) Process asynchronously
Don’t do heavy work directly inside the webhook request.
Instead:
- Receive webhook
- Verify signature
- Store event or enqueue job
- Return
200 OK - Process in background
This prevents timeouts and improves reliability.
8) Add observability
Track:
- Delivery attempts
- Success/failure rate
- Response codes
- Latency
- Dead-letter queue items
- Duplicate events
This makes troubleshooting much easier.
9) Test with a staging environment
Before going live:
- Create a test webhook endpoint
- Use sample events
- Simulate retries and duplicate deliveries
- Verify signature validation
- Confirm the receiver is idempotent
Tools like these can help:
- Postman / Insomnia
- ngrok / Cloudflare Tunnel for local testing
- Webhook.site for inspection
10) Common workflow pattern
A typical app-to-app webhook workflow looks like this:
- User performs action in App A
- App A detects event
- App A sends webhook to App B
- App B verifies signature
- App B enqueues event
- Worker processes event
- App B updates its database / triggers automation
- App B logs success or failure
Example architecture
- App A: event producer
- Webhook delivery service: sends signed events
- App B endpoint: receives and verifies
- Queue/worker: processes events asynchronously
- DB/logging: stores event status
Good design tips
- Use versioned payloads:
version: "1.0" - Keep payloads small but complete enough
- Document event types clearly
- Include correlation IDs
- Make secrets rotatable
- Don’t rely on exact delivery timing
- Don’t use webhooks for guaranteed real-time synchronous logic
If you want, I can also provide:
- a sample webhook implementation in Node.js, Python, or Go, or
- a complete app-to-app webhook architecture diagram.