Open
Description
The webhook component has 2 parts:
- the client part, which handles receiving webhooks in a controller (provided in the component) which parses the payload into a RemoteEvent with a request parser (which is the integration point of that component) and then dispatches that RemoteEvent in a messenger message bus
- the server part, which allows sending webhooks to other systems
The documentation at https://symfony.com/doc/current/webhook.html covers only the client part (and does not really explain the case of custom events rather than the mailer and notifier events, as the section just has a note saying MakerBundle can help you)
This server part is currently totally undocumented.
The server part works by creating a Subscriber
(representing the recipient of that webhook, potentially instantiated based on settings stored in an entity for instance) and a RemoteEvent. It can then be sent:
- when using messenger, this is a matter of publishing a
SendWebhookMessage
in the bus (the component provides the handler for that message that will call the TransportInterface) - otherwise, it is your responsibility to use
Symfony\Component\Webhook\Server\TransportInterface
to send the event to the subscriber in the place where this is relevant in your architecture.
When sending a webhook, the POST request has the remote event as JSON body and the following headers (by default, as event names are configurable):
Webhook-Event
with the event nameWebhook-Id
with the id of the eventWebhook-Signature
with the signature, generated as a hmac (usingsha256
by default) of the concatenation of the event name, event id and body, using the secret of the subscriber. The value of the header provides the algorithm used for the signature (it looks likesha256=...
)