Webhook URL: Real-time Event Handling for Automated Workflows
What a webhook URL is, how it differs from polling and API calls, where to find one, and how to receive webhook events in an orchestrated workflow with signature checks.
TL;DR — A webhook URL is an HTTP endpoint you give to another service so it can call you when an event happens, such as a push, a payment, or an alert. It replaces polling with push. Because anyone with the URL can call it, treat the URL as a secret and verify request signatures.
When a commit lands on GitHub, a payment clears in Stripe, or a monitoring tool raises an alert, other systems usually need to react within seconds. Polling each service for changes is slow and wasteful. A webhook URL turns it around: the source service calls your endpoint when the event happens.
This page explains what a webhook URL is, how it compares with polling and regular API calls, and how to receive webhook events in an orchestrated workflow. For hardening an endpoint in depth, see webhook security best practices.
How Webhook URLs Work
A webhook URL is a unique, publicly reachable address that receives HTTP requests, usually POST. When you register this URL with a third-party service (the webhook provider), that service sends a payload to it whenever a subscribed event happens. GitHub and Stripe document the pattern for their events.
Key characteristics include:
- Event-Driven: Communication is initiated by the source system when an event occurs, not by the receiving system on a schedule.
- Public HTTP Endpoint: It’s a standard URL that can accept HTTP requests, making it universally compatible with web technologies.
- One-Way Communication: The source system sends data (the payload) to the webhook URL but doesn’t typically expect a complex response beyond a success/failure status code.
Webhooks vs. APIs: Pull vs. Push
The fundamental difference between a webhook and a traditional API lies in the direction of communication. With an API, your application actively sends a request to an external service to pull data. With a webhook, the external service automatically pushes data to your application’s URL when an event occurs. This push model removes the need for constant polling.
Webhooks vs. Polling: Efficiency and Responsiveness
Polling involves repeatedly querying an API endpoint to check for new data. This is inefficient, as most requests return no new information, consuming network bandwidth and API rate limits. Webhooks send data only when there is something new, so they are cheaper and faster.
Why Webhook Events Need Orchestration
Receiving the request is the easy part. What happens next decides whether the integration is reliable:
- Data Validation and Transformation: Incoming payloads must be validated to ensure they conform to the expected schema. Data often needs to be cleaned, enriched, or transformed before it can be used by downstream systems.
- Security: A public URL can be called by anyone who has it. Keep the URL secret and authenticate each request, typically with an HMAC signature such as GitHub’s
X-Hub-Signature-256. - Error Handling and Retries: Downstream systems fail. The processing should retry with backoff and alert someone when retries run out, with the original payload kept for replay.
- Conditional Logic and Fan-Out: A single event might need to trigger different workflows based on its content. An orchestrator can route payloads to multiple downstream tasks or systems in parallel, applying conditional logic to decide which actions to take.
- Observability: When a webhook-triggered workflow fails, you need to know why. Centralized logging, monitoring, and alerting provide the necessary visibility to debug issues and ensure reliability.
Orchestrate Webhook Events with Kestra: A Secure Handling Scenario
In Kestra, a Webhook trigger gives a flow its own URL:
https://{your-kestra-host}/api/v1/{tenant}/executions/webhook/{namespace}/{flowId}/{key}
In the open-source edition the tenant is main. The key in the path gates who can call the URL, so treat it as a shared secret: store it in Kestra secrets, never in the flow YAML, and rotate it if the URL leaks. The trigger’s signature property then verifies the provider’s HMAC before any execution is created.
The flow below receives GitHub webhook deliveries, lets Kestra verify their HMAC signature, and starts an execution only for push events.
id: secure_webhook_handlernamespace: company.team.infra
triggers: - id: github_webhook type: io.kestra.plugin.core.trigger.Webhook key: "{{ secret('GITHUB_WEBHOOK_KEY') }}" signature: header: X-Hub-Signature-256 algorithm: HMAC_SHA256 secret: "{{ secret('GITHUB_WEBHOOK_SECRET') }}" prefix: "sha256=" when: "{{ trigger.headers['X-GitHub-Event'] contains 'push' }}"
tasks: - id: process_payload type: io.kestra.plugin.core.log.Log message: "Push to {{ trigger.body.repository.full_name }} on {{ trigger.body.ref }} by {{ trigger.body.pusher.name }}"
errors: - id: alert_on_failure type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook url: "{{ secret('SLACK_WEBHOOK_URL') }}" payload: | {"text": "Webhook processing failed in {{ flow.id }} (execution {{ execution.id }})"}What This Flow Handles
- The URL: It is built from the namespace, the flow id, and the
keyfrom Kestra secrets. Copy it from the Triggers tab into the GitHub webhook settings. - Signature Check Before Execution: With the
signatureblock, Kestra computes the HMAC-SHA256 of the raw request body with the webhook secret and compares it with theX-Hub-Signature-256header. A missing or wrong signature gets a401and creates no execution. - Event Filter: The
whencondition reads theX-GitHub-Eventheader, so onlypushdeliveries start an execution, which logs the repository, branch, and pusher from the body; other events get a204. Header names keep the sender’s casing, and HTTP/2 clients and many proxies send them in lowercase, so check what arrives before writing the condition. - Fast Acknowledgement: By default the trigger answers
200as soon as the execution is created, which suits providers that expect a quick response. Setwait: trueandreturnOutputs: trueonly for callers that need the flow’s outputs synchronously; never for GitHub, which fails any delivery not answered with a 2xx within 10 seconds. - Audit Trail: Every accepted delivery is an execution with its logs, and processing failures reach Slack through the
errorsbranch. Rejected requests create no execution; GitHub’s delivery log shows their401.
Ready to orchestrate your infrastructure?
Where Webhook URLs Pay Off
Webhook-driven automation fits many domains:
- CI/CD Pipeline Triggers: Automatically start a build, test, or deployment workflow when code is pushed to a Git repository.
- Real-time Alerts and Notifications: Ingest alerts from monitoring systems like PagerDuty or Grafana to trigger automated remediation runbooks.
- Data Synchronization: Keep systems in sync by reacting to events like a new customer created in a CRM or a successful payment in Stripe.
- IoT Events: Every webhook call creates a Kestra execution, so keep webhooks for low-rate device events. For telemetry streams, devices publish to an MQTT or Kafka broker and a Kestra Realtime trigger reacts to the messages.
Related concepts
- Event-Driven Orchestration: Learn more about building reactive, event-based systems.
- API Orchestration: Discover how to coordinate workflows that involve multiple API calls.
- HMAC Signature Validation Blueprint: A ready-to-use blueprint for secure webhook handling.
- Infrastructure Automation with Kestra: Explore how Kestra can orchestrate your entire infrastructure.
Terraform, Ansible and Kubernetes, orchestrated from one place.
Related resources
Frequently asked questions
Find answers to your questions right here, and don't hesitate to Contact Us if you couldn't find what you're looking for.