{"id":51045296,"url":"https://github.com/whilesmartphp/eloquent-webhooks","last_synced_at":"2026-06-22T13:02:14.700Z","repository":{"id":356625498,"uuid":"1233342337","full_name":"whilesmartphp/eloquent-webhooks","owner":"whilesmartphp","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-15T23:03:56.000Z","size":183,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-06-16T00:06:24.414Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whilesmartphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-08T21:22:01.000Z","updated_at":"2026-05-11T09:22:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whilesmartphp/eloquent-webhooks","commit_stats":null,"previous_names":["whilesmartphp/eloquent-webhooks"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/eloquent-webhooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-webhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-webhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-webhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-webhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/eloquent-webhooks/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-webhooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34649822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-22T13:02:13.265Z","updated_at":"2026-06-22T13:02:14.686Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Webhooks\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/whilesmart/webhooks.svg?style=flat-square)](https://packagist.org/packages/whilesmart/webhooks)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/whilesmart/eloquent-webhooks/tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/whilesmart/eloquent-webhooks/actions?query=workflow%3Atests+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/whilesmart/webhooks.svg?style=flat-square)](https://packagist.org/packages/whilesmart/webhooks)\n\nA comprehensive webhook management package for Laravel applications. Easily manage, track, and process incoming webhooks with built-in support for workspace and project scoping.\n\n## Features\n\n- **Webhook Management:** Complete CRUD operations for webhooks.\n- **Secure Ingress:** Automatic token generation for secure, unique webhook endpoints.\n- **Signed Outbound Delivery:** Queued, retried, HMAC-signed delivery of events to customer URLs.\n- **Polymorphic Ownership:** Any model (team, workspace, user, ...) can own a webhook.\n- **Event Tracking:** Logs all incoming webhook payloads, headers, and processing status.\n- **API Ready:** Comes with pre-configured controllers and routes for rapid development.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require whilesmart/eloquent-webhooks\n```\n\nYou should publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --tag=\"webhooks-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"webhooks-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    // Use UUID primary keys instead of auto-incrementing integers.\n    'uuids' =\u003e (bool) env('WEBHOOKS_UUIDS', false),\n\n    'register_routes' =\u003e env('WEBHOOKS_REGISTER_ROUTES', true),\n    'route_prefix' =\u003e env('WEBHOOKS_ROUTE_PREFIX', ''),\n    'route_middleware' =\u003e ['auth:sanctum'],\n\n    // Signed, retried outbound delivery.\n    'signing' =\u003e [\n        'header' =\u003e env('WEBHOOKS_SIGNATURE_HEADER', 'X-Webhook-Signature'),\n        'algo' =\u003e env('WEBHOOKS_SIGNATURE_ALGO', 'sha256'),\n    ],\n    'delivery' =\u003e [\n        'timeout' =\u003e (int) env('WEBHOOKS_DELIVERY_TIMEOUT', 10),\n        'max_attempts' =\u003e (int) env('WEBHOOKS_DELIVERY_MAX_ATTEMPTS', 6),\n        'backoff' =\u003e [10, 60, 300, 1800, 7200, 21600],\n        'queue' =\u003e env('WEBHOOKS_DELIVERY_QUEUE', null),\n        'connection' =\u003e env('WEBHOOKS_DELIVERY_CONNECTION', null),\n    ],\n    'auto_disable_after' =\u003e (int) env('WEBHOOKS_AUTO_DISABLE_AFTER', 15),\n];\n```\n\n## Usage\n\n### Managing Webhooks\n\nThe package provides a `Webhook` model that you can use to manage your webhooks.\n\n```php\nuse Whilesmart\\Webhooks\\Models\\Webhook;\n\n$webhook = Webhook::create([\n    'name' =\u003e 'My Webhook',\n    'owner_type' =\u003e $team-\u003egetMorphClass(), // any model may own a webhook\n    'owner_id' =\u003e $team-\u003eid,\n    'created_by_type' =\u003e $user-\u003egetMorphClass(), // optional creator audit\n    'created_by_id' =\u003e $user-\u003eid,\n    'is_active' =\u003e true,\n]);\n\n// Get the unique ingress URL\necho $webhook-\u003eurl; // https://your-app.com/webhooks/ingress/{token}\n```\n\n### Webhook Ingress\n\nIncoming webhooks are sent to a unique URL containing a secure token. When a webhook is triggered:\n1. The token is validated.\n2. The `trigger_count` and `last_triggered_at` fields are updated.\n3. A `WebhookEvent` is recorded containing the payload and headers.\n4. If `whilesmart/activities` is installed, an activity log is automatically created.\n\n### Outbound Webhooks\n\nOutgoing 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):\n\n```php\n$webhook = Webhook::create([\n    'user_id' =\u003e $user-\u003eid,                 // creator (audit)\n    'owner_type' =\u003e $team-\u003egetMorphClass(), // the owner that scopes the webhook\n    'owner_id' =\u003e $team-\u003eid,\n    'direction' =\u003e Webhook::DIRECTION_OUTGOING,\n    'url' =\u003e 'https://customer.example.com/hooks',\n    'subscribed_events' =\u003e ['whatsapp.message.received', 'whatsapp.message.status'],\n]);\n// $webhook-\u003esecret is generated automatically and used to sign deliveries.\n```\n\nFire an event to every matching active webhook:\n\n```php\napp(WebhookDispatcher::class)-\u003edispatch(\n    'whatsapp.message.received',\n    ['from' =\u003e '+15551234567', 'text' =\u003e 'hi'],\n    ['owner_type' =\u003e $team-\u003egetMorphClass(), 'owner_id' =\u003e $team-\u003eid],\n);\n\n// Or, on a model using the HasWebhooks trait:\n$team-\u003etriggerWebhook('whatsapp.message.received', $payload);\n```\n\nEach match creates a `WebhookDelivery` and queues a `DeliverWebhook` job that POSTs the JSON payload with these headers:\n\n- `X-Webhook-Id`, `X-Webhook-Event`, `X-Webhook-Delivery` (stable id for deduplication), `X-Webhook-Timestamp`\n- `X-Webhook-Signature: sha256=\u003chmac\u003e` where the HMAC is `hash_hmac('sha256', \"{timestamp}.{body}\", secret)` (header name and algorithm configurable)\n\nNon-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`.\n\n### API Endpoints\n\nBy default, the package registers the following routes (protected by `auth:sanctum`):\n\n#### Management Routes\n- `GET /webhooks`: List all webhooks for the authenticated user.\n- `POST /webhooks`: Create a new webhook.\n- `GET /webhooks/{id}`: Get webhook details.\n- `PATCH /webhooks/{id}`: Update a webhook (or regenerate its token).\n- `DELETE /webhooks/{id}`: Soft delete a webhook.\n- `GET /webhooks/{id}/events`: List event history for a webhook.\n\nThe built-in CRUD routes scope webhooks to the authenticated user as owner. To manage webhooks\nowned by another model (a team, workspace, etc.), set the `owner` morph directly and authorize\naccess with your own policy.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-webhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Feloquent-webhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-webhooks/lists"}