Blog

Get notified when your Mailcoach webhooks fail

Mailcoach has a powerful webhook feature that can send or notify any app or service of your choice whenever someone subscribes or unsubscribes from one of your email lists. A common use case for these webhooks is keeping an external database in sync with Mailcoach.

In the latest release of the self-hosted version of Mailcoach, we’ve improved how things are handled when your webhook fails. Mailcoach will now disable the webhook and notify you if a webhooks fails a couple of times in a row. Of course, you can specify how many attempts we should make before disabling the webhook.

This feature was added as a non-breaking change in v6. If you want to use this feature make sure you update the Mailcoach config file and publish and run the add_failed_attempts_to_webhook_configurations_table migration.

php artisan vendor:publish --tag=mailcoach-config --force

This will override your old configuration file with the new one. Using a git diff you can then re-apply any changes you previously made to your configuration file. Don’t forget to run the migration.

php artisan migrate

Take a look at the code snippet below to see how you can configure this feature in your Mailcoach settings:

// In config/mailcoach.php

return [
    /**
	 * The number of consecutive failures after which a webhook configuration
	 * will be disabled. This feature is opt-in and needs to be enabled 
	 * in the 'opt_in_features' configuration.
	 */
	'maximum_attempts' => 5,

    /**
	 * The email addresses receiving notifications
	 * when a webhook is automatically disabled.
	 */
	'notified_emails' => null,
];

In v6 this feature is opt-in. If you want to make use of it, you have to enable it.

// In config/mailcoach.php

return [
	'opt_in_features' => [
		'disable_failed_webhooks' => true,
	],
];

Ready to get started?