mock_rule_create_from_entry
Create or extend a mock rule from a captured traffic entry, matching request variants by method, path, and body/query fields, then patch live responses or serve recorded fixtures.
Instructions
Create or extend the rule for one request variant (method + path + body/query
values) from a captured entry.
match_body_fields picks the variant, e.g. ["/action"] for POSTs; leave it empty
for GETs. host_scope="any" (default) applies the rule on every routed host, since
the same API runs on several hosts; "exact" limits it to the entry's host, and
host accepts a glob such as .example.com. match_path replaces the entry's
exact path with a pattern where * stands for one segment or part of one, for
segments that differ by platform or app version: /api//payoneer covers
/api/p24-aos2/payoneer and its iOS twin. It must cover the entry's path.
mode="patch": the real server answers; request_patches edit the request body,
request_headers set (or remove with null) request headers before it is forwarded,
response_patches edit only the named response fields. mode="fixture": answer from
the captured response with any status (e.g. 500), never contacting the server
(request edits are ignored). status overrides the response code in either mode;
delay_ms waits that many milliseconds before answering, to test loaders and client
timeouts. merge=true adds to the variant's existing rule; a patch on the same
pointer replaces the old one. Patches are checked against the captured entry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | No | ||
| mode | No | patch | |
| merge | No | ||
| source | Yes | ||
| status | No | ||
| rule_id | No | ||
| delay_ms | No | ||
| entry_id | Yes | ||
| priority | No | ||
| capture_id | No | ||
| host_scope | No | any | |
| match_path | No | ||
| description | No | ||
| recording_path | No | ||
| request_headers | No | Request headers to change before the request is forwarded upstream (patch mode only): {"X-App-Version": "9.9.9", "X-Debug": null}. A value sets or replaces the header; null removes it. Host and Content-Length are managed by the dispatcher and cannot be set. | |
| request_patches | No | JSON Pointer edits: {"op": "set", "path": "/data/balance", "value": 0} or {"op": "remove", "path": "/data/banner"}; "/items/-" appends. Address array elements by a field, not an index, since servers may reorder them: "/data/balanceList/[currency=USD]/balance". | |
| response_patches | No | JSON Pointer edits: {"op": "set", "path": "/data/balance", "value": 0} or {"op": "remove", "path": "/data/banner"}; "/items/-" appends. Address array elements by a field, not an index, since servers may reorder them: "/data/balanceList/[currency=USD]/balance". | |
| match_body_fields | No | JSON Pointers into the captured request body whose values the rule must match, e.g. ["/action"]. JSON and form bodies are supported. | |
| match_query_fields | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rule | Yes | ||
| warnings | No | ||
| next_step | Yes | ||
| rule_json | Yes | ||
| fixture_file | No | ||
| archived_previous | No |