Skip to content

Get alerted when traffic changes

Before you begin

Plan
Included in Pro and Team. How plans and limits work
Role
Viewer or higher to see alert rules and Admin or higher to create, change, pause or delete a rule.
You need
  • To alert a webhook, a workspace Owner with a confirmed email address
  • To email someone outside the workspace, their address [confirmed under Settings](/guides/workspaces/alert-email-addresses/)

An alert rule watches one project’s recent traffic and tells someone when it crosses a line you set, so nobody has to watch Insights to notice that a client changed or a backend slowed down.

  1. Open the project’s Alerts tab.

  2. Select New rule.

  3. Enter a Rule name that no other rule in the project has, such as Error rate above 5%.

  4. Under Alert when, choose what to watch: Match rate falls below, Error rate rises above or p95 latency rises above.

  5. Enter the Threshold, such as 5. The box beside it shows its unit: % for the two rates, ms for latency.

  6. In Measured over, choose how much recent traffic to look at: 5 minutes, 15 minutes or 1 hour.

  7. Under Then tell, choose the Channel: Email or Webhook.

  8. For Email, choose who to email in Send to: a workspace member, or an address listed under Alert email addresses whose owner confirmed it. For Webhook, enter the Webhook URL; with no receiver yet, select Send to this project’s inbox instead, and read what arrives in the project inbox.

  9. In Stay quiet for, enter how many minutes the rule waits after it fires before it can fire again: 60 unless you change it, 0 to alert on every check.

  10. Check the sentence at the bottom of the dialog, which reads the rule back, such as “When the match rate is below 5% over 15 minutes, email ops@acme.test. Then stay quiet for 1 hour.”

  11. Select Create rule.

The dialog stays open when you select anywhere outside it. Closing it with Close, Cancel or Escape after changing anything asks first: Keep editing goes back to what you entered, and Discard changes closes it.

A webhook rule then opens a dialog named after it, such as Error rate above 5% is ready, with the rule’s Signing secret. Select Copy, give the secret to your receiver, and select Done. This is the only time it is shown without being asked for.

An Unused mocks rule watches the project’s mocks rather than its traffic. It tells someone when active mocks go a whole period without a request, so a project with hundreds of mocks does not keep ones nobody uses.

  1. Open the project’s Alerts tab, select New rule and enter a Rule name, such as Unused for 30 days.

  2. Under Alert when, choose Unused mocks.

  3. In Threshold, enter how many mocks passing the mark it takes, as a whole number: the field reads More than 0 mocks, and 0 alerts for any.

  4. In Unused for, choose how long a mock must go without a request: 7 days, 14 days, 30 days, 60 days or 90 days.

  5. Under Then tell, choose the Channel, then who to email in Send to or the Webhook URL.

  6. In Stay quiet for, keep 1440 minutes, a day, or enter another number.

  7. Check the sentence that reads the rule back, such as “When more than 0 active mocks go 30 days without a request, email ops@acme.test with their names. Each mock is reported once. Then stay quiet for 24 hours.”, and select Create rule.

A mock counts once it has gone the whole period without a request, counted from its last request, or from when it was created or last activated if that is later; Find mocks nobody calls says what counts as a request. Only active mocks count, and each is reported once, when it passes the mark: the next alert names only mocks that passed it since. A mock that is called again, or deactivated and activated again, starts its count again and is reported again if it passes the mark again. Changing the rule’s Unused for, threshold, channel or target reports every unused mock once more.

A Contract violations rule counts the invalid checks of the project’s background contract checks, so someone hears when responses stop matching the contract. It needs a plan with OpenAPI contract checks; without one, saving the rule is refused.

  1. Open the project’s Alerts tab, select New rule and enter a Rule name, such as Contract broken.

  2. Under Alert when, choose Contract violations.

  3. In Threshold, enter how many violations it takes, as a whole number: the field reads More than 0 violations, and 0 alerts for any.

  4. In Measured over, choose 1 hour, 6 hours or 24 hours.

  5. Under Then tell, choose the Channel, then who to email in Send to or the Webhook URL, and select Create rule.

The rule adds up the invalid checks recorded by runs inside the window. Each run is counted once: a violation that keeps happening is counted again only by the later runs that check it, and a rule that fires does not count the same runs again. Changing the rule’s threshold, window, channel or target counts them afresh. It counts a sample, so it measures how often sampled responses failed, not how many of your requests did, and it counts nothing the checks did not run for, such as while they are off.

Rule Fires when, over the window
Match rate falls below The share of requests a mock answered is below the threshold, as when a client calls a new endpoint
Error rate rises above The share answered with a 5xx status is above the threshold
p95 latency rises above The time within which 95% of requests were answered is longer than the threshold
Contract violations More sampled responses than the threshold failed the contract, in runs of the last 1, 6 or 24 hours

The match rate leaves out posts to the webhook inbox and requests the mock server gave no answer to, because neither says whether a mock would have matched. The p95 latency leaves out any delay a mock adds, so a mock you made slow on purpose does not fire it.

A Contract violations rule reads the stored runs of the background checks, not request logs, so the stored-request rules below do not apply to it either.

An Unused mocks rule fires when more active mocks than its threshold have gone its period, in days, without a request since it last fired. It reads no request logs, so nothing below about stored requests applies to it.

MockHub checks every rule that is not paused every five minutes, against the window just ended. After firing, a rule stays quiet for the time you set.

A rule counts the project’s stored request logs from the window, and nothing else. Every stored request counts, whatever answered it: a mock, the upstream, the webhook inbox or MockHub itself with an error such as a 502. A request that was not stored is left out entirely: everything while Store request logs is off, the unmatched 404s while Log requests no mock answered is off, requests refused before they reached the project, such as a 429, and deleted logs. A rule fires only when the window holds at least five stored requests, so one failed request on a quiet project does not alert anyone.

Requests a running chaos profile shaped are the exception: no rule counts an injected error, a cut connection or an added delay, so a chaos test alerts nobody. The rule’s dialog says so under the measure: “Requests caused by chaos are not counted, so a drill does not fire it.” The request log tags those requests, such as Injected error.

An Email alert has the subject [MockHub] Error rate above 5% triggered for Orders API: the rule’s name and the project’s. It gives the measured value, the threshold and the window, and links to the project’s insights. It goes to a workspace member who has confirmed their email address, or to an alert recipient: an address outside the workspace that its owner confirmed. Send to lists the workspace’s members and its confirmed addresses. A member marked “email not confirmed” cannot be chosen until they confirm their address. An address marked “not delivering” can be chosen, but MockHub is not emailing it: see what the states mean. A saved address that is neither a member nor listed any more stays selected, marked “not a member or confirmed address”, until you choose another. Saving a rule to anyone else is refused under the field.

This is checked each time an alert is sent, not only when you save the rule. A rule that emails someone who has since left the workspace, or an address since removed from the list, sends nothing and does not start its quiet period.

An email to an alert recipient ends with Stop alert emails from this workspace to this address, and mail apps show an unsubscribe button for it; see Stop alert emails as a recipient. An email to a member has neither, and links to the project’s Alerts tab instead.

An Unused mocks email says how many active mocks have gone the period without a request and names up to ten of them, then “and 5 more”. Its button, Open unused mocks, opens the project’s Mocks tab showing the active mocks unused for the rule’s period.

A Contract violations email says how many sampled responses broke the contract in the window and names up to ten operations. Its button, Open contract health, opens the project’s Insights on Contract health.

A Webhook alert is a POST to your URL, signed with the rule’s own secret, with a body like this:

{
"event": "alert.triggered",
"project": { "id": "0199a3c2-7a41-7d2e-9b0f-3c5e8d1a2b4f", "name": "Orders API" },
"rule": { "id": "0199a3c5-1b2d-7e4f-8a90-6c1d2e3f4a5b", "name": "Error rate above 5%" },
"metric": "error_rate_above",
"value": 0.083,
"threshold": 0.05,
"windowMinutes": 15,
"firedAt": "2026-09-30T09:35:00+00:00"
}

metric is match_rate_below, error_rate_above, latency_p95_above, unused_mocks_above or contract_violations_above. For the two rates, value and threshold are fractions, 0.05 for 5%; for latency they are milliseconds.

For unused_mocks_above, value is how many mocks passed the mark since the rule last fired, threshold is the rule’s whole number, and windowMinutes is the period in minutes: 43200 for 30 days. The body also lists the mocks in mocks, at most 50, longest unused first, each with the time since when no request has matched it:

{
"event": "alert.triggered",
"project": { "id": "0199a3c2-7a41-7d2e-9b0f-3c5e8d1a2b4f", "name": "Orders API" },
"rule": { "id": "0199a3c5-1b2d-7e4f-8a90-6c1d2e3f4a5b", "name": "Unused for 30 days" },
"metric": "unused_mocks_above",
"value": 2,
"threshold": 0,
"windowMinutes": 43200,
"firedAt": "2026-11-02T09:35:00+00:00",
"mocks": [
{
"id": "0199a3d1-4c2e-7f10-8b3a-2d4e6f8a0b1c",
"name": "GET /orders/{id} 404",
"idleSince": "2026-09-14T08:00:00+00:00"
},
{
"id": "0199a3d1-4c2e-7f10-8b3a-2d4e6f8a0b1d",
"name": "POST /refunds",
"idleSince": "2026-09-30T13:00:00+00:00"
}
]
}

For contract_violations_above, value is the number of violations counted, threshold the rule’s whole number and windowMinutes the window: 60, 360 or 1440. The body adds the contract’s revision and operations, at most 50, each with its method, pathKey, origin and violations. The pathKey is normalized: /orders/{id} becomes /orders/{}.

It carries these headers:

Header Value
Content-Type application/json
User-Agent MockHub-Webhook/1
X-MockHub-Alert-Rule-Id The rule’s id, the same as rule.id in the body
X-MockHub-Delivery The delivery’s id, a UUID. The same on every attempt of one alert; a replay has its own
X-MockHub-Cause alert, or replay for a replay
X-MockHub-Timestamp When this attempt was signed, in Unix seconds
X-MockHub-Signature v1= and the HMAC-SHA256 of the timestamp, a full stop and the body, made with the rule’s secret

The signature is made exactly as a webhook’s, so the code in Verify webhook signatures checks it with the rule’s secret in place of the webhook’s.

The URL must be a public http:// or https:// address, checked when you save the rule and each time an alert is sent; see Where a webhook can send. It also needs an Owner of the workspace with a confirmed email address, except for the project’s own webhook inbox, a good place to see what an alert sends.

Each webhook alert is a delivery of its rule, kept for 30 days and retried as a webhook’s is: an attempt that gets no answer, or a 408, 429 or 5xx, is tried again 30 seconds and then 5 minutes later, three attempts in all. Webhook signatures and retries lists every outcome. Anyone in the workspace can read the deliveries:

  1. Open the project’s Alerts tab.

  2. Select Deliveries on the rule.

  3. Select Details on a delivery to see what was sent and what came back.

The list works as a webhook’s does, with the cause An alert fired; see Inspect and replay webhook deliveries. An Editor can select Replay on a delivery, confirmed with Replay, to send its body again as a new delivery signed with the rule’s current secret. A replay counts against the alerts’ sending allowance, and is unavailable while the rule is Paused.

When a rule’s newest delivery has failed, its row on the Alerts tab shows Last delivery failed. An email alert keeps no record, so an email rule has no deliveries.

Each rule has a switch. Turn it off to pause the rule, which then shows Paused, and on to start it again. Edit opens the rule; saving a paused rule does not start it. To delete a rule, select the delete button named after it, such as Delete Error rate above 5%, then Delete rule.

A rule you start again judges only the traffic since then, so a breach from while it was paused alerts nobody. Changing what a rule watches or where it sends, in Alert when, Threshold, Measured over, Channel or the address or URL, ends its quiet period, so the changed rule can fire at the next check. Renaming it or changing Stay quiet for does not.

An Unused mocks rule you start again is the exception: unused mocks are a state, not traffic, so it reports the mocks that passed the mark while it was paused.

Pausing a rule also stops the retries of its alerts: an attempt still to come fails with The alert rule was paused before the delivery could run. Deleting a rule deletes its deliveries.

A webhook rule has a More actions menu for an Admin. Show secret shows the rule’s signing secret again. Rotate secret, confirmed with Rotate secret, replaces it: alerts are signed with the new secret at once, retries included, so a receiver still holding the old one rejects them until you give it the new one. Switching a rule from Email to Webhook gives it a secret, shown once when you save it, as on creation.

The rule appears in the list, such as “Error rate above 5% over 15 minutes.” with “Email to ada@example.com · then quiet for 1 hour” below it. It says “Has not fired yet” until the first alert, and then “Last fired” with the time.

  • A match-rate rule needs Log requests no mock answered on in the project’s settings, and shows Cannot fire without it: the unmatched 404s are then not stored, so only forwarded requests and MockHub’s own errors can lower the rate.
  • A cut connection looks the same as a mock server that failed. While a chaos profile with connection faults runs and covers the path, MockHub puts every failed connection down to chaos, so no rule counts a real failure there either.
  • No rule fires while the project cannot run: while the workspace is suspended, is still waiting for its first checkout or is a demo that has ended, or while the project is archived or beyond the number of projects the plan lets run. The plan sets how many alert rules a workspace can have, across all its projects; the limits page lists the number.

The count beside Alerts covers every project in the workspace. When that shared allowance is full, New rule shows “This workspace has used every alert rule its plan allows.” instead of opening.

A rule’s name is unique in its project. Saving a second one with the same name shows, under Rule name, “An alert rule named “Error spike” already exists in this project.”

  • There is no alert on request volume.
  • An Unused mocks rule counts days, not minutes, and reads only what MockHub has already recorded: a request still being processed when the rule is checked is counted at a later check.
  • A rule counts as fired, and starts its quiet period, once its email or its webhook delivery is queued, even if the delivery then fails. While one of its deliveries is still Pending or Retrying, the rule sends nothing new, however short its quiet period. An email held back because the workspace has three outgoing requests under way, counting webhook deliveries, alerts and forwards together, or any alert held back because the sending allowance is used up, is tried again at the next check.
  • An email alert to an address MockHub is not emailing, because earlier mail to it bounced, its recipient asked not to get mail, or an alert recipient stopped this workspace’s alerts, is not sent but still counts as fired and against the sending allowance. Its row shows Email not sent: at once for a stopped alert recipient, otherwise once the rule has fired to that address. Change the address, or ask its owner to resume: an alert recipient from the stop link in an earlier alert email, anyone else as Mail is not arriving describes. The first alert to an address that then bounces is not flagged, because the bounce arrives after it was sent.
  • Alerts have a daily and monthly sending allowance of their own. Email alerts count against the plan’s alert email allowance, which is much smaller than its webhook delivery allowance; the limits page lists both numbers. Webhook alerts and replays count against an allowance as large as the plan’s webhook delivery allowance. Each alert and each replay counts once; retries do not. For a lot of alerts, send them to a webhook and forward them from there.

Report a problem with this page