Webhooks
Start workflows instantly when another system sends an event.
Modern applications often need to communicate immediately. When a customer places an order, a business may need to update inventory, notify shipping, create a CRM activity, and send confirmation without waiting for someone—or another system—to check for changes. Webhooks make this event-driven communication possible.
What Is a Webhook?
A webhook is a mechanism that lets one application send event data automatically to a URL in another application when a specific event occurs. The receiving URL is called a webhook endpoint. It usually accepts an HTTP POST request containing a JSON payload.
For example, after a contact form is submitted, the website sends the form data to an automation platform's webhook URL. Receiving that request starts the workflow immediately.
How Webhooks Work
| Stage | What Happens | Example |
|---|---|---|
| 1. Subscribe | A receiving system registers or provides a webhook URL | A workflow provides its production endpoint to a payment service |
| 2. Event | A relevant event occurs in the source system | A payment succeeds |
| 3. Delivery | The source sends an HTTP request and event payload | A POST request includes transaction details |
| 4. Acknowledge | The receiver returns a success response quickly | HTTP 200 or 204 |
| 5. Process | The workflow validates and handles the event | Update the order and notify the customer |
{
"id": "evt_8f31",
"type": "support.ticket.created",
"createdAt": "2026-07-20T08:30:00Z",
"data": {
"ticketId": "T-1042",
"customer": "Asha Rao",
"message": "I cannot access my dashboard after upgrading."
}
}Webhooks vs Polling
Polling means repeatedly asking a service whether anything has changed. A webhook sends a notification only when an event occurs. It is like receiving a message when an online order is ready instead of calling the restaurant every five minutes.
| Characteristic | Webhook | Polling |
|---|---|---|
| Initiated by | The source system after an event | The receiving system on a schedule |
| Speed | Usually near real time | Depends on the polling interval |
| Requests | Sent when events occur | Sent even when nothing changed |
| Offline handling | Requires retry or durable receipt | Can fetch missed changes later |
| Best fit | Immediate event-driven workflows | Services without webhook support or periodic synchronization |
Webhooks and APIs
APIs and webhooks are complementary. An API call begins when your workflow requests data or an action. A webhook begins when another system reports an event. A common pattern is to receive a lightweight webhook and then call an API to retrieve the complete, current record before processing it.
Payment service sends payment.succeeded webhook
-> Verify sender and event
-> Acknowledge receipt
-> Fetch current payment and order through APIs
-> Update inventory and CRM
-> Send confirmation
-> Record completionCreating a Webhook Endpoint with Flask
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.post("/webhooks/support")
def receive_support_event():
payload = request.get_json(silent=True)
if not payload or not payload.get("id") or not payload.get("type"):
return jsonify({"error": "Invalid event"}), 400
# In production: verify the signature, store the event ID,
# enqueue durable processing, and ignore duplicates.
print("Received:", payload["type"], payload["id"])
return jsonify({"status": "accepted"}), 202
if __name__ == "__main__":
app.run(port=5000)The example demonstrates the receiving shape, but a production endpoint also needs sender verification, HTTPS, duplicate protection, durable processing, safe logging, and monitoring.
Using Webhooks in Workflow Platforms
In n8n, Make, or Zapier, a webhook trigger provides a URL and waits for a sample request. The sample helps the platform identify fields that can be mapped into later steps. Use the test URL only while building; production workflows should use the platform's production URL and remain enabled.
- Create a webhook trigger and copy its generated URL.
- Configure the source application to send the desired event to that URL.
- Send a representative sample event and inspect its headers and payload.
- Validate required fields and map data into subsequent actions.
- Test expected events, bad input, duplicates, retries, and downstream failures.
- Activate the production workflow and monitor live deliveries.
Webhooks in AI Automation
- Summarize and classify a support ticket as soon as it is created.
- Extract structured lead information from a new form submission.
- Analyze a newly uploaded document and route the result for review.
- Generate a draft reply when an approved messaging event arrives.
- Detect the language and intent of a chatbot message before choosing an action.
- Create an incident summary when monitoring software sends an alert.
Treat webhook content as untrusted input, even when it will be sent to an AI model. Validate its structure, restrict its size, separate instructions from data, and require human review for sensitive or irreversible actions.
Securing a Webhook Endpoint
- Use HTTPS so event data is encrypted in transit.
- Verify the provider's signature using the raw request body and a protected signing secret.
- Compare signatures safely and reject requests whose timestamps fall outside an acceptable window.
- Validate the content type, event type, schema, field values, and payload size.
- Use least-privilege downstream credentials and keep secrets out of URLs, source code, and logs.
- Apply rate limits and network restrictions when supported.
- Return a generic error response rather than revealing internal implementation details.
A secret value included in the webhook URL can add protection, but it should not replace the provider's documented signature-verification method. Never trust a request only because its payload looks correct.
Duplicate Events and Idempotency
Webhook providers may retry an event when a response is slow or lost, so the same event can arrive more than once. Use the provider's unique event ID as an idempotency key. Record it atomically before applying side effects, and return success without repeating the work when that ID has already been processed.
Receive event evt_8f31
-> Verify signature and schema
-> Has evt_8f31 already been processed?
Yes: acknowledge and stop
No: record ID -> enqueue work -> acknowledge
-> Worker performs actions onceFast Acknowledgement and Asynchronous Processing
Many providers expect a successful response within a short time. Verify the request, store the event durably, place work on a queue, and acknowledge it quickly. A separate worker can then call AI services, update databases, and send notifications. This avoids provider timeouts and makes retries easier to control.
Failure Handling
- Expect temporary network errors, timeouts, duplicate delivery, out-of-order events, and downstream outages.
- Use bounded retries with increasing delays for temporary failures.
- Move repeatedly failing events to a dead-letter queue or manual-review path.
- Do not assume events always arrive in creation order; compare timestamps or retrieve current state when order matters.
- Create a reconciliation job when missing an event would have serious consequences.
- Preserve the event ID, type, attempt number, and correlation ID for troubleshooting.
Monitoring and Troubleshooting
- Track delivery count, accepted and rejected requests, processing success, duplicate rate, latency, and queue depth.
- Alert on signature failures, repeated processing errors, growing queues, and unusual event volume.
- Log metadata needed for diagnosis while redacting secrets and sensitive payload fields.
- Use the provider's delivery history and request IDs to investigate failed attempts.
- Provide a safe replay process that still honors idempotency checks.
- Document the event owner, schema, downstream actions, and recovery procedure.
Common Use Cases
- Payment completion and refund notifications
- Contact forms, registrations, and lead capture
- Order, shipping, and inventory events
- Support tickets and CRM updates
- File uploads and document-processing workflows
- Email, messaging, and chatbot events
- Source-code, deployment, and monitoring events
- AI classification, extraction, summarization, and routing
Best Practices
- Subscribe only to events the workflow actually needs.
- Verify authenticity before trusting or processing a request.
- Validate payloads and use explicit handling for supported event types.
- Design every handler to tolerate duplicate and out-of-order delivery.
- Acknowledge quickly and move slow work to a durable queue.
- Combine retry limits, dead-letter handling, reconciliation, and alerting.
- Use separate development and production endpoints and secrets.
- Version payload contracts and monitor integrations when providers change them.