Mautic webhooks in production: duplicates, ordering, retries and timeouts
This guide covers the problems Mautic webhooks cause in production and how to handle each one. Mautic's webhook docs carry a banner saying they need a major update, and they say little about delivery behaviour, so several answers here come from Mautic's sender code, read at version 7, and the guide says where that's the case. What Mautic sends and how to set it up is on the Mautic webhooks overview, every event type is on Mautic webhook events, and signature verification code is on Verify Mautic webhooks.
At a glance
| Problem | What to do | With Event Gateway |
|---|---|---|
| Timeouts | Store the event, return a 2xx and process it afterwards | Accepts the delivery at once, then queues it for your service |
| Retries | Choose the delivery mode deliberately; don't return 410; watch for unpublished webhooks | Stores each delivery and retries to your service on your schedule |
| Duplicates | Build a key from the event type, the object's ID and timestamp | Drops repeats based on the fields you choose |
| Ordering | Compare stored state or timestamp before you apply a change | Delivers at a rate your service can handle |
| Choosing events | Know what each event leaves out; don't rely on email opens | Filters and routes on the body |
| Testing | Trigger a real event as well as Send Test Payload | Forwards to localhost and replays past events |
| Other limits | Loop over every key and item; check field names against a real delivery | Verifies the signature and logs every delivery |
Mautic webhook timeouts and slow handlers
Store the event, return a 2xx and do the work afterwards. Mautic's docs state no timeout, so don't plan around one.
Why it happens: In real-time mode, Mautic's source sends the request while it handles the action that caused it, so a slow endpoint slows Mautic too. Its config has a webhook_timeout setting of 15 seconds, but the sender code we read doesn't apply it. Check how your own version behaves before you rely on that value.
Fix it in your handler:
- Verify the signature, store every item in the request and respond straight away. See why to process webhooks asynchronously.
- Keep the request path free of calls to other services.
- If real-time delivery slows your Mautic instance, consider queued mode, which sends from a cron job rather than during the action.
With Event Gateway: Hookdeck accepts each Mautic delivery immediately, then queues it and delivers it to your service at a rate it can handle. Your handler can take as long as it needs without holding up Mautic.
Mautic webhook retries and unpublished webhooks
Real-time deliveries aren't retried. Queued deliveries are retried by later cron runs, and a webhook that keeps failing gets unpublished. Mautic's docs cover none of this, so all of it comes from its source.
Why it happens:
- Real-time mode. A failed delivery is logged and dropped, because Mautic never stored the event.
- Queued mode. After a non-2xx response, the items stay in the database and later cron runs send them again once
webhook_retry_delayhas passed, an hour by default. After a connection error, the next run sends them again. The code we read sets no maximum number of retries. - Unpublishing. A
410unpublishes the webhook at once. Mautic also unpublishes a webhook when none of the last 100 entries in its log (webhook_disable_limit) is a success, or fewer entries if the log is shorter. It skips this ifdisable_auto_unpublishis set or the webhook was edited in the last two days.
Fix it in your handler:
- Pick the mode deliberately. Real-time delivery is immediate with no retries, and queued delivery retries but adds the cron interval to every event.
- Return
410from your webhook route only if you mean "stop sending". - Check that your webhooks are still published after any outage.
- After an outage in real-time mode, reconcile from the Mautic API for the objects you care about.
With Event Gateway: Hookdeck answers Mautic with a 2xx as soon as it has stored the request, then retries towards your service on your schedule. Failures on your side no longer count against the webhook or lose real-time events.
Duplicate Mautic webhooks
Deduplicate on each item, not each request, using a key you build yourself. Mautic sends no event ID.
Why it happens: After a failed queued request, Mautic's source sends the same items again, and they can land in a different batch from the first attempt. If your handler stored some items before it failed, the retry repeats them.
Fix it in your handler:
- Build a key from the event type, the main object's ID (contact, submission, company) and the item's
timestamp, which is when Mautic queued the event and doesn't change between attempts. It's only accurate to the second, so two changes to one contact in the same second share a key. - Store processed keys with a unique constraint. See our guide to webhook idempotency.
- Return a 2xx only once every item in the request is stored, so that a failure can't drop part of a batch.
With Event Gateway: Hookdeck's deduplication can drop repeated requests based on the fields you choose. It works on whole requests, so keep per-item keys for batches.
Out-of-order Mautic webhooks
Don't assume items arrive in the order they happened. Compare timestamp or your stored state before you apply a change.
Why it happens: In queued mode, the Order of the queued events setting makes batches chronological or reverse chronological. In Mautic's source, failed items also sort after fresh ones, so a retried item can arrive after a newer event about the same contact. Mautic's docs don't describe the order of real-time deliveries.
Fix it in your handler:
- Use Chronological if you run queued mode and the order matters.
- Store each object's latest
timestamp, and skip an older item. - When only the current state matters, fetch the object from the Mautic API.
With Event Gateway: Hookdeck queues deliveries and sends them at a rate your service can handle, which reduces overlap between handlers. It doesn't restore the original order, so keep the timestamp check.
Choosing Mautic events
Subscribe only to the events you process, and create one webhook per app or script, as Mautic recommends, so that each secret is exposed in as few places as possible.
What to watch for:
mautic.lead_means a contact was identified, not that a record was created. Mautic's source sends nothing for anonymous contacts on either save event.post_ save_ new mautic.email_on_opendepends on a tracking pixel. Mautic's docs say proxies and bots can load it, so don't drive critical logic from it. In Mautic's source this event sends astatobject, although the docs point to the properties ofmautic.email_on_send.- Deletion events carry the ID in
id, because thecontactorcompanyobject that comes with them has a nullid. mautic.lead_list_changecovers segment membership. Mautic's sender registers it, although the docs don't list it.
With Event Gateway: Hookdeck can filter and route on the body, so you can send each event type to the service that needs it.
Testing Mautic webhooks
Use Send Test Payload to check that the URL and signature work, then trigger a real event to see a real body.
Why it happens: In Mautic's source, the button posts static fixture files rather than anything from your instance. Their data is old, and the shape differs from a real delivery in several ways:
mautic.form_on_submit,mautic.page_on_hitandmautic.email_on_openarrive as a bare object rather than an array, with notimestamp.- The
mautic.lead_fixture has nopoints_ change pointsobject. - Company events,
mautic.lead_,company_ change mautic.email_on_send,mautic.sms_on_sendandmautic.lead_list_changehave no fixture and are left out, so a webhook with only those selected posts an empty[].
How to test:
- Click Send Test Payload to check the URL and signature. It signs with the secret currently in the form.
- Submit a form or edit a contact to send a real event. Mautic's docs describe no way to resend a delivery, so keep a copy of the body.
- Mautic 7 rejects private network addresses unless they're in the
webhook_setting, so aallowed_ private_ addresses localhostURL won't work without it. Use a public tunnel instead.
With Event Gateway: The Hookdeck CLI forwards events to localhost, and you can replay past events from the dashboard while you work on your handler.
Other Mautic webhook limits
Batched bodies. Each top-level key is an event type holding an array. A real-time request has one key and one item, and a queued request can hold several of each. In Mautic's source, each request holds up to 10 items by default (webhook_limit), and a cron run keeps sending until the queue is empty or webhook_time_limit passes, 600 seconds by default. Loop over every key and every item.
Unreliable docs. Mautic's own banner says its webhook pages need a major update. They also disagree with its source in places: the mautic.lead_post_delete page names the object company, while the sender uses contact. Check field names against a real delivery from your version.
No replay protection. The signature covers only the body, with no signed timestamp, so a captured request stays valid. Keep the endpoint on HTTPS and rely on your idempotency keys.
Self-hosted senders. Every installation is its own sender, so there's no IP list to allow. Mautic's source sets X-Origin-Base-URL to the instance's URL. The administrator controls the settings above, so check yours rather than assuming the defaults.
With Event Gateway: Hookdeck verifies the signature, then gives you one log of every request, so if your handler fails partway through a batch you can fix it and replay the whole request.
Stop losing real-time Mautic events when your endpoint is down.
Mautic's source doesn't retry real-time deliveries. Hookdeck Event Gateway accepts each one, verifies its signature, queues it and retries to your service on your schedule.