Events | laravel-webhook-server | Spatie       

 SPATIE  

==

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-webhook-server](https://spatie.be/docs/laravel-webhook-server/v4)  Events

 Version   v4      

 Other versions for crawler [v4](https://spatie.be/docs/laravel-webhook-server/v4) 

  Events    
- [ Introduction ](https://spatie.be/docs/laravel-webhook-server/v4/introduction)
- [ Installation and setup ](https://spatie.be/docs/laravel-webhook-server/v4/installation-and-setup)
- [ Sending webhooks ](https://spatie.be/docs/laravel-webhook-server/v4/sending-webhooks)
- [ Signing requests ](https://spatie.be/docs/laravel-webhook-server/v4/signing-requests)
- [ Retrying failed webhooks ](https://spatie.be/docs/laravel-webhook-server/v4/retrying-failed-webhooks)
- [ Transport options ](https://spatie.be/docs/laravel-webhook-server/v4/transport-options)
- [ Events ](https://spatie.be/docs/laravel-webhook-server/v4/events)
- [ Testing webhooks ](https://spatie.be/docs/laravel-webhook-server/v4/testing-webhooks)
- [ Upgrading from v3 ](https://spatie.be/docs/laravel-webhook-server/v4/upgrading)

 Events
======

###  On this page 

1. [ Queued listeners ](#content-queued-listeners)
2. [ Handling delivery failures ](#content-handling-delivery-failures)

The package fires these events in the `Spatie\WebhookServer\Events` namespace:

- `DispatchingWebhookCallEvent`: before dispatching the webhook to the queue. Synchronous dispatch does not fire this event.
- `WebhookCallSucceededEvent`: the receiver returned a final `2xx` response.
- `WebhookCallFailedEvent`: an attempt failed, whether or not another attempt will follow.
- `FinalWebhookCallFailedEvent`: no further attempts will be made.

All events expose `httpVerb`, `webhookUrl`, `payload`, `headers`, `meta`, `tags`, and `uuid`. The UUID stays the same across attempts. Headers include the signature when signing is enabled. Raw payloads are strings; JSON payloads are arrays.

Except for `DispatchingWebhookCallEvent`, events also expose:

- `attempt`: the attempt number.
- `response`: an `Illuminate\Http\Client\Response`, or `null` when no response was received.
- `errorType` and `errorMessage`: the exception class and message, or `null` for a successful attempt.
- `transferStats`: a `GuzzleHttp\TransferStats` instance, or `null`.

Use `$event->response?->status()`, `body()`, `json()`, or `headers()` to read the HTTP result. HTTP errors report Laravel's `RequestException`; connection failures report its `ConnectionException`.

Queued listeners
--------------------------------------------------------------------------------------------------------

Listeners may implement Laravel's `ShouldQueue` interface. HTTP bodies, status codes, header arrays, cookies and transfer statistics survive queue serialization, including the request and response inside the statistics. Listeners receive reconstructed Laravel responses and Guzzle statistics; synchronous listeners keep their original objects.

Webhook jobs and dispatching/result events use base64 encoding to preserve binary raw/custom bodies, headers, metadata and error messages through Laravel's JSON queue payloads. This increases message sizes and is not encryption. Check your queue's limits and protect access to sensitive request and response data. Custom metadata, cookie jars and handler data must still be serializable. Custom response subclasses and their additional runtime state are not preserved.

Seekable streams retain their original positions. Non-seekable streams are read once and cached while the original stream exists, preserving identical bytes across shared statistics and repeated serialization. The first snapshot consumes the original stream; buffer or replace it before dispatching events if synchronous listeners also need to read it. Bytes already consumed by middleware cannot be recovered.

Handling delivery failures
--------------------------------------------------------------------------------------------------------------------------------------

Listen to `WebhookCallFailedEvent` for every failed attempt, or `FinalWebhookCallFailedEvent` to act only when delivery has stopped. The package does not log every delivery exception for you.

Enable `throw_exception_on_failure` or call `throwExceptionOnFailure()` to mark the underlying queue job as failed and rethrow its exception on the final failure.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
