Create a chaos profile
Before you begin
- Role
- Admin or higher.
- You need
- A project with mocks
A chaos profile is a named way for a project’s mocks to misbehave, so you can see how your client copes with a slow or failing API without editing a single mock. Creating a profile changes nothing: it takes effect only while it runs, which you start separately.
-
Open the project’s Chaos tab.
-
Select New profile.
-
Enter a Profile name, such as
Flaky payments. -
To affect only some mocks, enter an Endpoint pattern, such as
^/payments. Leave it empty to affect every mock, and every request forwarded to the upstream. -
Turn on one or more effects, and fill in their fields, as described below.
-
Select Create profile.
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.
An AI assistant connected over MCP creates a profile with create_chaos_profile, with the same effects and endpoint pattern, and runs it with start_chaos_profile. It needs a personal token and the Admin role, as the dialog does; see MCP tools.
The effects
Section titled “The effects”A profile needs at least one effect. Each has its own switch.
Latency delays every response it covers. On a mock it replaces the mock’s own delay; on a request forwarded to the upstream it is added to the time the upstream takes. Choose the delay type and fill in its fields: Fixed takes Delay (ms); Random range takes Minimum (ms) and Maximum (ms); Realistic (lognormal) takes Median (ms) and Sigma, which default to 200 and 0.4, and is mostly near the median with occasional slow responses. The types work as for a mock’s own delay; see Add a delay to a mock.
Error injection answers a share of calls with an error instead of the mock’s response, or, on a forwarded request, instead of calling the upstream. Set the Share of calls (%) and the Status code. Response body replaces the mock’s body on those calls; left empty, they have none. Add header adds a response header, such as Retry-After with 30. To simulate rate limiting this way, see Simulate rate limiting with 429 and Retry-After.
Connection fault breaks the connection instead of answering, for a Share of calls (%). Choose Connection reset by peer, Empty response, Malformed response chunk or Random data, then close. Whichever you choose, your caller receives a 502 from MockHub with the body Mock did not answer, or Upstream connection failed on a forwarded request, not a broken connection.
Each call is decided afresh: with a share of 30%, about three calls in ten are affected. When a call is picked for both a fault and an error, the fault wins.
The endpoint pattern
Section titled “The endpoint pattern”The pattern is a regular expression. For a mock it is compared with the path as written on the mock, not with the path of each request. ^/payments covers mocks for /payments and /payments/42, and, for a Regex mock, compares with its expression, such as /payments/[0-9]+. For a request forwarded to the upstream it is compared with the request’s own path, without the query, so ^/payments covers /payments/42 too. Without ^ and $ it matches anywhere in the path: orders also covers /v1/orders/42.
Result
Section titled “Result”MockHub shows Chaos profile created, and the profile appears on the Chaos tab with its effects, such as Fixed 2000 ms or HTTP 503 on 30% of calls, and “Applies to paths matching ^/payments.” or “Applies to every mock and forwarded request.” To run it, see Start and stop chaos.
Edit changes a profile, and the change applies at once if the profile is running. The delete button on a profile’s row, such as Delete Flaky payments, removes it; a running profile must be stopped first. If its run has ended but some of its effects are still in place, deletion removes them too. If the mock server cannot be reached, the profile stays in the list; retry deletion when the server answers again.
Limits
Section titled “Limits”- The plan sets how many chaos profiles a workspace can have, across all its projects; the limits page lists the number. Profile names are unique within a project.
- On a mock, latency replaces its own delay. On a forwarded request it is added to the upstream’s own time. A delay longer than the plan’s simulated-delay limit is cut to that limit.
- The body and headers of an injected error are sent exactly as written: templates in them are not rendered.
- A connection fault always reaches your caller as a
502. For an answer that arrives but is wrong, use error injection with the body you want. - Chaos covers requests a mock answers and, in Proxy unmatched, requests forwarded to the upstream. An injected error or connection fault is answered without calling the upstream, so it spends none of the upstream allowance and is never a capture. It never affects the Record everything gateway mode, or an unmatched request in Mock only.