CLOUD CONCEPT

Webhooks

Webhooks are event-triggered HTTP callbacks that notify another application when something happens.

Cloud Concepts Hub →

What is Webhooks

A webhook lets an event producer send a request to a registered endpoint instead of requiring the consumer to repeatedly poll for changes. Engineers use webhooks to trigger builds and tests, integrate enterprise applications, and start asynchronous AI workflows, while explicitly handling authentication, retries, and duplicate deliveries.

A webhook is an integration pattern in which an application sends an HTTP request to a configured callback URL when a selected event occurs. The request commonly uses HTTPS POST and contains a JSON payload describing the event, its identifier, and relevant resources. Unlike polling, where a consumer repeatedly asks whether anything changed, a webhook pushes a notification when the producer detects a change. This can reduce unnecessary requests and shorten the time between an event and its processing.

In CI/CD, a source repository can send webhook events when developers open or update pull requests or merge code. A build service can filter these events and run compilation, unit tests, security checks, or integration tests. For example, AWS CodeBuild supports webhook-triggered builds for supported repository providers. Configure filters for the intended event types and branches rather than building on every repository action. A merge may be represented by a pull-request-merged event or by a push to the destination branch, depending on the provider and integration. Selecting overlapping triggers can cause duplicate builds.

Starting a build is not the same as enforcing a merge gate. Publish test results through the repository integration and configure branch protection or repository rules to require the appropriate checks. Treat code from untrusted pull requests as potentially hostile: it can change build scripts and attempt to extract credentials. Use restricted build roles, isolate execution, and avoid exposing deployment secrets to untrusted contributions.

For enterprise integrations, an HTTPS endpoint can receive events from a ticketing system, customer relationship management application, or document platform. An API gateway routes requests to a webhook handler, which validates the sender, checks the payload, and accepts work for asynchronous processing. For example, Amazon API Gateway and AWS Lambda can receive a ticket-created event, then publish a normalized event to Amazon EventBridge or place work on Amazon SQS. A downstream worker can invoke a generative AI model to summarize the ticket or draft a response, then update the originating application through its API.

Webhook handlers should return a successful response promptly, but only after the event has been durably accepted for processing. Performing a long build or model invocation before responding risks exceeding the sender's timeout. A successful acknowledgment usually means the notification was accepted, not that the business workflow completed. Track completion separately and design status updates so they do not create notification loops.

Security depends on the producer's supported authentication mechanism. When signatures are available, verify them using the documented algorithm and the original request bytes; parsing and reserializing JSON can invalidate a signature. Use timestamps and delivery identifiers to help reject replays, rotate signing secrets, and enforce payload limits. HTTPS protects transport but does not, by itself, prove that the caller is the expected application. In AI workflows, treat event text as untrusted input and do not allow embedded instructions to grant tool access or bypass authorization.

Webhooks do not inherently guarantee delivery, ordering, or exactly-once processing. Retry policies vary by sender, and timeouts can cause redelivery even when processing succeeded. Make consumers idempotent using a stable event identifier, use bounded retries and dead-letter handling downstream, and monitor delivery failures and processing lag. For critical integrations, provide reconciliation against the source system because receiver-side queues cannot recover an event that never arrived. Webhooks provide lightweight connectivity, but they are not a substitute for a durable message broker or a complete workflow engine.

Key aspects of Webhooks

Reliable webhooks combine selective event delivery with authenticated requests, durable asynchronous processing, idempotency, and controlled execution.

Event-driven HTTP delivery

The producer calls a registered endpoint when a selected event occurs, reducing the need for frequent polling. The receiver must expose an endpoint reachable by the producer and understand its event contract.

Selective automation triggers

Filter by event type, repository, branch, or other supported attributes to start only the intended builds or workflows. Check for overlapping pull-request and push triggers that could execute the same work twice.

Authenticated and validated requests

Verify the producer's signature or other supported credentials before trusting an event, and validate its schema and size. Protect signing secrets and apply replay defenses appropriate to the producer's protocol.

Fast acknowledgment with durable handoff

Persist or enqueue accepted events before returning success, then perform slow work asynchronously. An HTTP acknowledgment should not be mistaken for confirmation that a build, test suite, or AI task finished.

Idempotency and failure recovery

Expect duplicate deliveries and potentially missing or out-of-order events. Deduplicate using stable identifiers, retry transient failures, and provide dead-letter handling and reconciliation for important workflows.

Controlled execution of untrusted input

Repository contributions and enterprise event payloads can contain hostile code or text. Isolate builds, restrict permissions, and ensure AI-generated actions remain subject to application authorization and validation.

Cloud services for Webhooks

For CI/CD, CodeBuild can consume supported repository webhook events directly and run filtered build or test jobs. For custom enterprise integrations, API Gateway exposes the endpoint and Lambda validates the request before durably handing off work. EventBridge routes normalized events to interested consumers, while SQS buffers work and supports controlled retries. A downstream worker can call Amazon Bedrock for an AI task and update the originating application through its API. Keep webhook acknowledgment separate from workflow completion, and carry event identifiers through the components for deduplication, tracing, and failure investigation.

AWS CodeBuild image AWS CodeBuild

Uses repository webhooks to start builds and tests for supported source providers. Webhook filter groups select relevant events and branches; repository rules must separately enforce required checks before merging.

Open AWS CodeBuild →
Amazon API Gateway image Amazon API Gateway

Provides an HTTPS entry point for custom webhook integrations and routes requests to backend handlers. Configure throttling and request handling appropriately, and preserve the request representation needed for signature verification.

Open Amazon API Gateway →
AWS Lambda image AWS Lambda

Runs webhook handlers that authenticate requests, validate payloads, and hand events to downstream services. Keep the request path short and use least-privilege execution roles.

Open AWS Lambda →
Amazon EventBridge image Amazon EventBridge

Routes normalized webhook events to downstream targets using event patterns. EventBridge API Destinations can also send events to external HTTPS endpoints; an event bus is not itself a general-purpose public webhook receiver.

Open Amazon EventBridge →
Amazon Bedrock

Provides model inference for downstream tasks such as summarizing incoming tickets or drafting responses. Invoke it from an authorized worker after webhook validation rather than treating the model service as the webhook receiver.

Open Amazon Bedrock →