PHPackages                             whilesmart/eloquent-webhooks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. whilesmart/eloquent-webhooks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

whilesmart/eloquent-webhooks
============================

Webhook management package for Laravel applications

032[1 issues](https://github.com/whilesmartphp/eloquent-webhooks/issues)PHPCI passing

Since May 10Pushed 1mo agoCompare

[ Source](https://github.com/whilesmartphp/eloquent-webhooks)[ Packagist](https://packagist.org/packages/whilesmart/eloquent-webhooks)[ RSS](/packages/whilesmart-eloquent-webhooks/feed)WikiDiscussions dev Synced 3w ago

READMEChangelog (1)Dependencies (13)Versions (6)Used By (0)

Eloquent Webhooks
=================

[](#eloquent-webhooks)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4720bbf07fc446d8ec282e2b2f140ec39b55a664fa7b58c6d4ab4310cdd54687/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7768696c65736d6172742f776562686f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/whilesmart/webhooks)[![GitHub Tests Action Status](https://camo.githubusercontent.com/74b4f2af76edf4e75c9915838d75db3f4c4763c69687d5a06843a67d6129c4de/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7768696c65736d6172742f656c6f7175656e742d776562686f6f6b732f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/whilesmart/eloquent-webhooks/actions?query=workflow%3Atests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/efc904e7ce00bd40106e27feb90949854da8001ed06f8d6da6d290bcfe35f050/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7768696c65736d6172742f776562686f6f6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/whilesmart/webhooks)

A comprehensive webhook management package for Laravel applications. Easily manage, track, and process incoming webhooks with built-in support for workspace and project scoping.

Features
--------

[](#features)

- **Webhook Management:** Complete CRUD operations for webhooks.
- **Secure Ingress:** Automatic token generation for secure, unique webhook endpoints.
- **Signed Outbound Delivery:** Queued, retried, HMAC-signed delivery of events to customer URLs.
- **Polymorphic Ownership:** Any model (team, workspace, user, ...) can own a webhook.
- **Event Tracking:** Logs all incoming webhook payloads, headers, and processing status.
- **API Ready:** Comes with pre-configured controllers and routes for rapid development.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require whilesmart/eloquent-webhooks
```

You should publish and run the migrations with:

```
php artisan vendor:publish --tag="webhooks-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="webhooks-config"
```

This is the contents of the published config file:

```
return [
    // Use UUID primary keys instead of auto-incrementing integers.
    'uuids' => (bool) env('WEBHOOKS_UUIDS', false),

    'register_routes' => env('WEBHOOKS_REGISTER_ROUTES', true),
    'route_prefix' => env('WEBHOOKS_ROUTE_PREFIX', ''),
    'route_middleware' => ['auth:sanctum'],

    // Signed, retried outbound delivery.
    'signing' => [
        'header' => env('WEBHOOKS_SIGNATURE_HEADER', 'X-Webhook-Signature'),
        'algo' => env('WEBHOOKS_SIGNATURE_ALGO', 'sha256'),
    ],
    'delivery' => [
        'timeout' => (int) env('WEBHOOKS_DELIVERY_TIMEOUT', 10),
        'max_attempts' => (int) env('WEBHOOKS_DELIVERY_MAX_ATTEMPTS', 6),
        'backoff' => [10, 60, 300, 1800, 7200, 21600],
        'queue' => env('WEBHOOKS_DELIVERY_QUEUE', null),
        'connection' => env('WEBHOOKS_DELIVERY_CONNECTION', null),
    ],
    'auto_disable_after' => (int) env('WEBHOOKS_AUTO_DISABLE_AFTER', 15),
];
```

Usage
-----

[](#usage)

### Managing Webhooks

[](#managing-webhooks)

The package provides a `Webhook` model that you can use to manage your webhooks.

```
use Whilesmart\Webhooks\Models\Webhook;

$webhook = Webhook::create([
    'name' => 'My Webhook',
    'owner_type' => $team->getMorphClass(), // any model may own a webhook
    'owner_id' => $team->id,
    'created_by_type' => $user->getMorphClass(), // optional creator audit
    'created_by_id' => $user->id,
    'is_active' => true,
]);

// Get the unique ingress URL
echo $webhook->url; // https://your-app.com/webhooks/ingress/{token}
```

### Webhook Ingress

[](#webhook-ingress)

Incoming webhooks are sent to a unique URL containing a secure token. When a webhook is triggered:

1. The token is validated.
2. The `trigger_count` and `last_triggered_at` fields are updated.
3. A `WebhookEvent` is recorded containing the payload and headers.
4. If `whilesmart/activities` is installed, an activity log is automatically created.

### Outbound Webhooks

[](#outbound-webhooks)

Outgoing webhooks deliver your application's events to a customer-supplied URL. Create one with `direction` set to `outgoing`, the destination `url`, and the `subscribed_events` it should receive (omit `subscribed_events` to receive all):

```
$webhook = Webhook::create([
    'user_id' => $user->id,                 // creator (audit)
    'owner_type' => $team->getMorphClass(), // the owner that scopes the webhook
    'owner_id' => $team->id,
    'direction' => Webhook::DIRECTION_OUTGOING,
    'url' => 'https://customer.example.com/hooks',
    'subscribed_events' => ['whatsapp.message.received', 'whatsapp.message.status'],
]);
// $webhook->secret is generated automatically and used to sign deliveries.
```

Fire an event to every matching active webhook:

```
app(WebhookDispatcher::class)->dispatch(
    'whatsapp.message.received',
    ['from' => '+15551234567', 'text' => 'hi'],
    ['owner_type' => $team->getMorphClass(), 'owner_id' => $team->id],
);

// Or, on a model using the HasWebhooks trait:
$team->triggerWebhook('whatsapp.message.received', $payload);
```

Each match creates a `WebhookDelivery` and queues a `DeliverWebhook` job that POSTs the JSON payload with these headers:

- `X-Webhook-Id`, `X-Webhook-Event`, `X-Webhook-Delivery` (stable id for deduplication), `X-Webhook-Timestamp`
- `X-Webhook-Signature: sha256=` where the HMAC is `hash_hmac('sha256', "{timestamp}.{body}", secret)` (header name and algorithm configurable)

Non-2xx responses, timeouts, and connection errors are retried with exponential backoff up to `delivery.max_attempts`; after `auto_disable_after` consecutive failures the webhook is deactivated and a `WebhookDisabled` event is emitted. Run `php artisan webhooks:retry-stuck` (e.g. on a schedule) to re-enqueue any deliveries whose retry is due. Tune everything under the `delivery`, `signing`, and `auto_disable_after` keys in `config/webhooks.php`.

### API Endpoints

[](#api-endpoints)

By default, the package registers the following routes (protected by `auth:sanctum`):

#### Management Routes

[](#management-routes)

- `GET /webhooks`: List all webhooks for the authenticated user.
- `POST /webhooks`: Create a new webhook.
- `GET /webhooks/{id}`: Get webhook details.
- `PATCH /webhooks/{id}`: Update a webhook (or regenerate its token).
- `DELETE /webhooks/{id}`: Soft delete a webhook.
- `GET /webhooks/{id}/events`: List event history for a webhook.

The built-in CRUD routes scope webhooks to the authenticated user as owner. To manage webhooks owned by another model (a team, workspace, etc.), set the `owner` morph directly and authorize access with your own policy.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance61

Regular maintenance activity

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

73d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1ca6f6e01ecbfe6640ff410c4f0321054fb48d05a5f843c2b89887b90369bcd?d=identicon)[whilesmart](/maintainers/whilesmart)

---

Top Contributors

[![kofimokome](https://avatars.githubusercontent.com/u/21100923?v=4)](https://github.com/kofimokome "kofimokome (10 commits)")[![nfebe](https://avatars.githubusercontent.com/u/14317775?v=4)](https://github.com/nfebe "nfebe (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/whilesmart-eloquent-webhooks/health.svg)

```
[![Health](https://phpackages.com/badges/whilesmart-eloquent-webhooks/health.svg)](https://phpackages.com/packages/whilesmart-eloquent-webhooks)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[crumbls/layup

A visual page builder plugin for Filament 5 — Divi-style grid layouts with extensible widgets.

592.8k2](/packages/crumbls-layup)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3518.3k](/packages/duncanmcclean-statamic-cargo)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
