Skip to content

Webhooks

Pro

Receive Lettermint webhook events (deliveries, bounces, complaints, …) as Craft events.

  1. In the Lettermint dashboard, create a webhook and choose its events. Use the endpoint URL shown below the Webhook Secret setting, e.g. https://example.com/actions/lettermint/webhook.
  2. Copy its signing secret (whsec_…) into Webhook Secret.
use SomehowDigital\Craft\Lettermint\events\WebhookEvent;
use SomehowDigital\Craft\Lettermint\services\WebhooksService;
use yii\base\Event;
Event::on(WebhooksService::class, WebhooksService::EVENT_RECEIVE_WEBHOOK, function (WebhookEvent $event) {
if ($event->type === WebhooksService::TYPE_MESSAGE_HARD_BOUNCED) {
$event->payload->id; // delivery ID
$event->payload->data; // event data, e.g. `recipient`
}
});

All event types are listed in the reference.

If a handler throws an exception, the endpoint answers 500 and Lettermint retries the delivery. See responses and retries.