/
WebsiteSupport

DocsDeveloper guideAPI and webhooks

Webhooks

The system receives provider notifications (payments, messages, shipping). It does not send webhooks to other systems at this commit.

1 min read

The shared inbox

Every integration gets one address: /integrations/hook/{token}. GET, POST and PUT are accepted, the token is 40 letters and digits, up to 600 calls a minute, and it is public with no CSRF (routes/web.php:148-153). Each call goes through WebhookInbox::receive (app/Support/Integrations/WebhookInbox.php:14-97):

  1. The token finds the integration and its company; an unknown token gets 404.
  2. A handshake (for example a challenge from a messaging provider) is answered by the driver's acknowledge().
  3. The driver checks the signature with verifyWebhook(). A bad one gets 401 and nothing is stored.
  4. An inactive integration answers 200 and stores nothing, so the provider stops retrying.
  5. The event is stored once, keyed by its event id; a repeat answers 200 "already received".
  6. It is handled at once or right after the answer. A failure is retried after 1, 5, 30, 120 and 720 minutes, then marked failed (app/Support/Integrations/WebhookInbox.php:29-30).

Other inbound addresses

AddressWhat sends itSource
GET/POST /pos/terminal/hook/{provider}/{token?}Card terminal resultsroutes/web.php:145
POST /mail/inboundThe inbound mail gateway, token-authenticatedroutes/api.php:27-28

Receiving webhooks in your add-on

Write an integration driver (see Payment, shipping and SMS drivers). Return true from receivesWebhooks(), check the provider's signature in verifyWebhook(), return ['id' => ..., 'topic' => ...] from webhookEvent(), and do the work in handleWebhook() (app/Support/Integrations/IntegrationDriver.php:121-171).

See also