set_rule_chaos
Configure Rule-level Chaos for a specific conditional rule inside a mock. Unlike Global Traffic Chaos (which intercepts all requests), Rule-level Chaos only activates when the rule's conditions have already matched. For example: rule matches 'name=agung', then 30% chance the connection is killed instead of returning the rule's normal response. Supports two modes: 'probability' (random per-request) and 'sequential_fail' (fail first N requests, then pass, cycling).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | 'probability': chaos fires randomly with failureRate probability on each request (0.0=never, 1.0=always). 'sequential_fail': chaos fires for the first maxFailCount requests in a cycle, then passes on the (maxFailCount+1)-th, then repeats. | |
| mockId | Yes | Database ID of the mock endpoint | |
| ruleId | Yes | Database ID of the rule to attach chaos to. Obtain from get_mock_detail. | |
| behavior | Yes | 'error_response': return this rule's configured responseStatus and responseBody normally. 'kill_connection': drop TCP connection — no HTTP response, client gets connection reset. | |
| projectId | Yes | Database ID of the project | |
| failureRate | No | Used when mode='probability'. Float between 0.0 (never fires) and 1.0 (always fires). E.g. 0.3 = 30% chance of chaos. | |
| maxFailCount | No | Used when mode='sequential_fail'. Number of consecutive requests that trigger chaos before one passes through. E.g. 3 = fail 3 times, pass once, repeat. | |
| resetAfterMs | No | Optional. For sequential_fail mode only: automatically reset the counter if no requests arrive within this many milliseconds. 0 = never auto-reset. |