DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

Laravel Webhooks: How to Send Events and Handle Callbacks

Send webhooks with Laravel’s HTTP client and receive callbacks through a narrowly exempted, signature-verified endpoint. Learn when to queue work and how to avoid duplicate side effects.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Laravel’s HTTP client to send webhook requests; for incoming callbacks, expose a reachable route, verify the sender’s signature, and acknowledge valid events promptly. Exclude only the webhook endpoint from CSRF checks when the provider cannot send a CSRF token. Queue slower processing when it makes sense, and make handlers safe to run more than once.

How Laravel webhooks work

A webhook is an HTTP request sent when an event occurs. Your Laravel application can send one to notify another system, or receive one when an external provider reports an event. These are separate flows: your outbound retry policy does not control whether a provider redelivers an incoming event.

As an Amazon Associate I earn from qualifying purchases.

Laravel 13.x provides an HTTP client for outbound requests. For receiving webhooks, Laravel supplies routing and request-forgery protections, while signature verification and event processing depend on the provider or package you use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to send a webhook from Laravel

For a small sender, Laravel’s HTTP client can build the request, set JSON data and headers, apply a finite timeout, and retry selected failures. The client does not throw automatically for every 4xx or 5xx response, so inspect the response explicitly or configure exception behavior. See the Laravel 13.x HTTP client documentation.

use IlluminateSupportFacadesHttp;

$response = Http::timeout(10)
    ->withHeaders(['X-Event-Id' => $eventId])
    ->post($destination, [
        'event' => 'invoice.paid',
        'data' => $payload,
    ]);

if ($response->failed()) {
    // Record the failure or handle it according to your retry policy.
}

This is an illustrative request shape, not a complete provider-specific protocol. Use the event name, payload fields, authentication headers, and signing procedure required by the receiving system. If the receiver requires signed webhooks, use its documented algorithm and canonicalization rules rather than assuming that a generic signature scheme will be accepted.

Set a deliberate timeout and retry policy

A finite timeout prevents a slow destination from holding the request open indefinitely. Retry only failures that are appropriate to retry, and choose a limit that fits your delivery requirements. A retry can repeat an operation if the receiver processed the first request but the response was lost. Include a stable event identifier and design the receiving side to recognize duplicates before performing non-idempotent work.

When a sender package is useful

Spatie Laravel Webhook Server provides a package-managed dispatch flow for signed webhook calls. Its documentation describes JSON payloads, an HMAC-SHA256 signature in a Signature header, and retries after unsuccessful non-2xx responses. The documented retry attempts occur after 10 seconds and then 100 seconds; these timings are package-specific defaults, not Laravel framework behavior or a universal webhook standard. Check the package’s current compatibility and configuration for your Laravel version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to receive a webhook in Laravel

Configure a publicly reachable POST endpoint at the URL expected by the provider. A webhook from an external server ordinarily cannot include the browser-session CSRF token Laravel expects, so exclude that endpoint from CSRF validation if necessary. The exclusion only disables the CSRF check; it does not prove who sent the request.

Exclude only the webhook route from CSRF checks

In Laravel 13, request-forgery protection can be configured with preventRequestForgery(except: [...]). Keep the exception narrow, limited to the webhook path. The Laravel 13.x CSRF documentation describes the configuration. For Stripe with Cashier, the documented exclusion pattern is stripe/*; follow the setup for your integration rather than excluding broad application paths.

Verify the signature before trusting the payload

Validate the signature using the provider’s secret and exact verification procedure before trusting payload fields or triggering business actions. Providers may sign a particular representation of the request body or require their own SDK; do not replace those requirements with a generic HMAC check. Keep signing secrets out of source control and use the provider’s current guidance for secret rotation.

For Stripe billing webhooks, Laravel Cashier’s Stripe webhook guidance covers its webhook route and signature middleware. Cashier registers a controller at /stripe/webhook by default. For more general signed webhook reception, Spatie Laravel Webhook Client provides a configurable signature validator and webhook route. Check each package’s current Laravel compatibility before installing it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Acknowledge promptly and move slow work off the request

Once a request has passed verification and the event has been recorded, return the acknowledgement the provider expects without waiting for slow application work. Dispatch heavier work to a job when appropriate. Spatie’s client stores incoming calls and supports queued processing; its documentation recommends a real queue driver rather than the sync driver for queued work. Cashier supports handling received events through listeners, where you implement the application-specific action.

Recording an event before processing helps separate delivery from business work and gives you a place to track failures. Whether you need persistence, replay, or a queue depends on the importance and volume of the event; a small, fast handler does not automatically require a queue.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Which Laravel webhook approach should you choose?

Need Approach What to consider
Make an ordinary outbound request or send a small webhook Laravel HTTP client Configure timeout, retries, response inspection, signing if required, and any persistence yourself. Laravel documentation.
Send signed events with package-managed dispatch Spatie Laravel Webhook Server Review its signing support, retry behavior, synchronous or queued dispatch, and fit with your receiving system. Package documentation.
Receive Stripe billing events Laravel Cashier (Stripe) Provides Stripe-oriented route handling and signature middleware; extend event handling with your own listeners. Cashier documentation.
Receive different types of signed webhooks and queue processing Spatie Laravel Webhook Client Configure the signature validator, endpoint, persistence, and queue behavior. Package documentation.
Receive Stripe events using Spatie’s receiver Spatie Laravel Stripe Webhooks Review Stripe verification, call persistence, event or job dispatch, and the application-specific logic you still need. Package documentation.

These options overlap. Choose one clear owner for receiving and processing an event instead of layering multiple handlers without a defined reason. A custom implementation is also viable when you have explicitly accounted for verification, persistence, retries, and operations.

Webhook reliability: prevent duplicate side effects

Retries are useful when a destination is temporarily unavailable, but delivery may be repeated. Treat each event as potentially delivered more than once: store its stable provider or event ID, check whether it has already been handled, and make the business action idempotent where possible. For an operation that cannot be repeated safely, record processing state and define how failed or incomplete work is recovered.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep outbound and inbound responsibilities distinct. Laravel’s HTTP client retries requests made by your application; an external provider controls its own redelivery policy for callbacks. Your endpoint should return the appropriate status for success or failure according to that provider’s delivery rules.

Version and compatibility notes

The framework instructions here refer to Laravel 13.x documentation for the HTTP client, CSRF protection, and Cashier. Package compatibility can change independently of framework documentation; confirm the current requirements and configuration for your Laravel release before adopting a Spatie package. No geography-specific behavior is established for these implementation steps.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.