Skip to main content

Update a rule (partial)

PATCH 

/v2/endpoints/:endpoint/rules/:ruleId

Performs a partial update of an existing mock rule. Only the fields provided in the request body are modified; all other fields remain unchanged.

Purpose:

  • Update specific rule fields without affecting others
  • Toggle rule enabled/disabled status
  • Modify individual conditions or actions
  • Update rule descriptions

How It Works:

  1. Partial Update: Only specified fields are updated
  2. Field Merging: Provided fields overwrite existing values; omitted fields remain unchanged
  3. ID Preservation: The rule ID cannot be changed
  4. Position Preservation: The rule maintains its position in the execution order
  5. Validation: Updated fields are validated before applying changes

Supported Partial Updates:

  • enabled: Toggle rule on/off without changing conditions or actions
  • description: Update the human-readable label
  • method: Change the HTTP method filter
  • conditions: Replace the entire conditions array
  • action: Replace the entire action object

Important Notes:

  • Complex fields like conditions and action are replaced entirely (not merged)
  • To update a single condition, you must provide the complete conditions array
  • To update action properties, you must provide the complete action object
  • Partial updates within nested objects are not supported

Common Use Cases:

Example 1: Toggle Rule Status

{
"enabled": false
}

Disables the rule without modifying conditions or actions.

Example 2: Update Description

{
"description": "Updated rule description"
}

Changes only the rule's label.

Example 3: Change HTTP Method

{
"method": "POST"
}

Updates the method filter while preserving conditions and actions.

Limitations:

  • Cannot move the rule to a different position
  • Nested object merging not supported (entire objects must be replaced)
  • All validation rules apply to updated fields

Response: Returns the complete updated rule with all fields (including unchanged ones).

Request

Responses

Rule updated