Skip to content

Package: webhooks

Generated from api/packages/webhooks

Source: api/packages/webhooks. The sections after the README are extracted from the code on every docs build.

Lets an academy (tenant) register https URLs that receive its domain events as signed, versioned JSON: HMAC-SHA256 signature with a timestamp (replay resistant), retries with exponential backoff through the queue, a delivery log with every attempt, test sends, replays and SSRF-safe target URLs. Phase 7.3 of docs/ROADMAP-PROMPT.md.

  • Guide for receivers and admins: front/docs-site/src/content/docs/developers/outgoing-webhooks.mdx
  • Endpoints: api/admin/webhooks/* (permission webhook_manage, token scope webhooks:read|write), documented in OpenAPI under the tag “Admin Webhooks”.
  • Events wired today: course.completed, enrolment.created, update_proposal.ready, update_proposal.applied, certificate.issued, course.version_applied, knowledge.exported, training.assigned, training.completed, training.overdue, path.completed, certificate.revoked, policy.change.approved, policy.retraining.assigned. Planned types are listed by GET /api/admin/webhooks/events.
domain event ─▶ EventCatalog (class → type, payload) ─▶ WebhookDispatcher
─▶ one WebhookDelivery per enabled, subscribed endpoint (payload stored as sent)
─▶ DeliverWebhookJob ─▶ DeliveryRunner ─▶ Ulams\Core\Http\SafeHttp (https, public IPs, pinned address, no redirects)
─▶ 2xx: succeeded | else: attempt logged, retry with backoff, after max attempts failed, endpoint disabled after N failed deliveries in a row

Registered in api/config/app.php. Then:

Terminal window
php artisan migrate
php artisan db:seed --class="Ulams\Webhooks\Database\Seeders\WebhookPermissionSeeder"
php artisan vendor:publish --tag=ulams_webhooks.config # optional

A queue worker must run for deliveries; the scheduler runs webhooks:retry-due every minute (retries whose job was lost, and every retry under the synchronous queue) and webhooks:prune daily.

src/config.php: api_version, max_endpoints, max_attempts, backoff_seconds, timeout, disable_after_failures, retention_days, rate limits. Environment: WEBHOOKS_ALLOW_INSECURE (local development only: http and private addresses), WEBHOOKS_ALLOWED_HOSTS, WEBHOOKS_QUEUE, WEBHOOKS_QUEUE_CONNECTION.

Add it to Support/EventCatalog.php (class name as a string, description, payload builder, sample) and to the table in the guide. tests/Feature/DomainEventsTest.php fails when an available type has no listener.

Terminal window
vendor/bin/phpunit --testsuite webhooks

The receiver is a Guzzle MockHandler bound as webhooks.http_handler; DNS is replaced through SafeHttp::useResolver, so no test touches the network.

Method Path Auth Action
GET /api/admin/webhooks/events yes WebhooksController@events
GET /api/admin/webhooks/endpoints yes WebhooksController@index
POST /api/admin/webhooks/endpoints yes WebhooksController@store
GET /api/admin/webhooks/endpoints/{endpoint} yes WebhooksController@show
PUT /api/admin/webhooks/endpoints/{endpoint} yes WebhooksController@update
DELETE /api/admin/webhooks/endpoints/{endpoint} yes WebhooksController@destroy
POST /api/admin/webhooks/endpoints/{endpoint}/rotate-secret yes WebhooksController@rotateSecret
POST /api/admin/webhooks/endpoints/{endpoint}/test yes WebhooksController@test
GET /api/admin/webhooks/deliveries yes WebhooksController@deliveries
GET /api/admin/webhooks/deliveries/{delivery} yes WebhooksController@showDelivery
POST /api/admin/webhooks/deliveries/{delivery}/replay yes WebhooksController@replay
Permission Seeded for roles Constant
webhook_manage admin WebhookPermissionEnum::WEBHOOK_MANAGE

Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).

None.

None.

Command Description Signature
webhooks:prune Delete webhook deliveries (and their attempts) older than the retention period webhooks:prune
webhooks:retry-due Queue webhook retries that are overdue (a lost job, or the synchronous queue) webhooks:retry-due {--grace= : Seconds a retry may be overdue before it is queued again}
Kind Target Frequency
command 'webhooks:retry-due' everyMinute()->withoutOverlapping()
command 'webhooks:prune' daily()

WEBHOOKS_ALLOW_INSECURE, WEBHOOKS_ALLOWED_HOSTS, WEBHOOKS_QUEUE, WEBHOOKS_QUEUE_CONNECTION