Webhooks: send MaintainHQ events to your own systems
Last updated
A webhook is a message MaintainHQ sends to your own system the moment something happens. Instead of your software asking MaintainHQ “has anything changed?” over and over, MaintainHQ tells it straight away: a backup finished, an update failed, a site went down.
You might use webhooks to log events in your own database, update a client record in your CRM, or start an automation in another tool. This guide covers setting up an endpoint, the events you can choose, what each message looks like, how to check it really came from MaintainHQ, and what happens when your system does not answer.
Webhooks or alerts?
MaintainHQ has two different things that can be called a webhook:
- Webhooks (this guide), under Settings: structured event data for software to read, signed so your system can trust it.
- The webhook alert channel, under Alert settings: formatted alerts meant for people, alongside Slack, Teams, email and the rest.
If you want a person to be told something, use alerts. If you want software to act on something, use webhooks.
Only the account owner or a team Admin can manage webhooks.
Adding an endpoint
An endpoint is the web address on your system that receives the events.
- Open Webhooks under Settings in the left-hand menu and press Add endpoint.
- Enter the Endpoint URL. It must be a public address starting with https://.
- Optionally add a Description, such as “Our client CRM”, so you know what it is for later.
- Under Events, tick the events you want. Select all ticks every event.
- Under Sites, leave “Every site, including ones added later” switched on, or switch it off and tick specific sites.
- Press Add endpoint.
- MaintainHQ shows the signing secret (it starts with whsec_). Copy it now and keep it on your receiving server. It will not be shown again.
An account can have up to 20 endpoints.
The events
| Event | When it is sent |
|---|---|
| site.connected | A WordPress site connected (or reconnected) to MaintainHQ. |
| site.disconnected | A site stopped answering the MaintainHQ connector for over 3 hours. |
| update.completed | A plugin, theme or WordPress core update finished. |
| update.failed | An update did not finish, including one that was interrupted. |
| update.rolled_back | An update was rolled back to the previous version. |
| backup.completed | A backup finished. |
| backup.failed | A backup failed. |
| incident.opened | An incident (for example the site going down) was opened for a site. |
| incident.resolved | An incident was resolved. |
| vulnerability.found | A known vulnerability was found on a site. |
| fix_plan.approved | A Gus fix plan was approved. |
| deploy.completed | A Git deploy finished successfully. |
| domain.expiring | A domain is close to its expiry date. |
| ssl.expiring | A site’s SSL certificate is close to expiry. |
There is also a test event, webhook.test, sent only when you press Send test event. You cannot subscribe to it.
What each message looks like
Each event is sent as an HTTP POST with a JSON body. JSON is a simple text format most programming languages read easily. The body always has these fields:
| Field | What it holds |
|---|---|
| id | A unique ID for the event. It stays the same on every retry and resend. |
| type | The event name, such as backup.completed. |
| created_at | When the event happened. |
| team | The account’s ID and name. |
| site | The site’s ID, name and address. Empty (null) for account-level events. |
| data | Details for that event, such as a backup’s type and size. |
The request also carries headers, including X-MaintainHQ-Event (the event type), X-MaintainHQ-Event-Id (the same as id), X-MaintainHQ-Delivery (unique to each attempt) and X-MaintainHQ-Signature.
Checking the signature
Anyone who knows your endpoint address could send it fake data. The signature lets your system prove a message really came from MaintainHQ.
The X-MaintainHQ-Signature header looks like “t=1763121600,v1=5f2c…”. The t part is a timestamp. The v1 part is an HMAC-SHA256 code: a fingerprint made by combining the timestamp, a full stop and the raw body with your signing secret.
- Read the raw body exactly as it arrived, before any JSON parsing. Re-encoded JSON will not match.
- Split the header on the comma into its t and v1 parts.
- Work out the HMAC-SHA256 of the timestamp, a full stop and the raw body, using your signing secret.
- Compare your result with v1 using a constant-time comparison, which most languages provide.
- Reject the message if the timestamp is more than 5 minutes away from your server’s clock. This stops someone replaying an old message.
Your developer will find ready-made code for this in most languages. The header name and an explanation are also shown at the top of the Webhooks page.
Answering, retries and switching off
Your endpoint should answer with any 2xx status code (such as 200 OK) within 10 seconds. Do slow work after you have answered.
Anything else, or no answer, counts as a failure. MaintainHQ tries again after 1, 2, 4, 8, 16, 32 and 64 minutes, so 8 attempts in all.
Testing, the delivery log and other settings
Each endpoint has its own card with an on/off switch and these buttons:
- Send test event: sends webhook.test straight away and tells you the response status and how long your endpoint took, or why it failed.
- Deliveries: shows the delivery log, with the event, status, response, time taken and when it was sent. Retrying deliveries show when the next attempt is due. Click a delivery to see the exact payload sent and the response. Use the resend button to send one again.
- Edit: change the URL, description, events or sites.
- Replace secret: creates a new signing secret. The old one stops working straight away, so update your server immediately.
- Delete (bin icon): stops events going to that URL and deletes its delivery log.
Deliveries are kept for 30 days.