add_mock_rule
Append a single new conditional response rule to an existing mock API endpoint without replacing or resending its existing rules array. Returns the full updated mock object (including the newly created rule's assigned database 'id' and 'slugId', the complete 'rules' array, and 'responseBodyWarning' if the rule's JSON responseBody looks malformed). USAGE GUIDELINES: Prefer add_mock_rule over update_mock whenever adding a new scenario to an existing mock — it is much more token-efficient and avoids accidentally overwriting existing rules or reassigning their rule IDs. Before calling, inspect existing rule priorities via get_mock_detail so you can set the new rule's 'priority' integer appropriately (rules are evaluated in ascending priority order; first match wins). After adding the rule, call test_mock with a matching request payload and verify the 'X-Rule-Matched' response header.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"projectId": "<projectId>",
"mockId": "<mockId>",
"rule": "<rule>"
},
"name": "add_mock_rule"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rule | Yes | A single conditional rule. Rules are evaluated in ascending priority order. The first rule whose conditions ALL match will override the mock's default response. If no rule matches, the mock's default responseBody/responseStatus is returned as the fallback. | |
| mockId | Yes | Database ID of the target mock API endpoint to append the rule to (obtain from list_mocks, search_mocks, or get_mock_detail). | |
| projectId | Yes | Database ID of the project workspace containing the mock (obtain from list_projects, search_mocks, or get_mock_detail). |