Skip to main content

Mock Loki is now Stage! Read the announcement

Back to blog
Product Updates5 min read

Introducing Mutation Rules v2: More Power, Less Complexity

Our biggest platform update yet brings JSON Path expressions, conditional logic, and a visual rule builder to make API mutation more powerful and accessible.

MR
Marcus Rodriguez
CTO & Co-founder
December 15, 2024

Today we're launching Mutation Rules v2, our biggest platform update since launch. This release makes Stage dramatically more powerful while also being easier to use.

What's New

JSON Path Expressions

You can now use JSON Path to surgically target specific fields in API responses:

json
{
  "match": { "path": "/api/products/*" },
  "action": {
    "type": "patch",
    "operations": [
      { "op": "replace", "path": "$.price.amount", "value": 0.01 },
      { "op": "add", "path": "$.flags", "value": ["test_mode"] }
    ]
  }
}

Conditional Logic

Rules can now include conditions that evaluate request or response data:

json
{
  "match": {
    "path": "/api/users/*",
    "conditions": [
      { "field": "$.role", "equals": "admin" }
    ]
  },
  "action": { "type": "latency", "ms": 5000 }
}

This is perfect for testing how your app handles slow responses for specific user types.

Visual Rule Builder

For teams who prefer a GUI, we've built a visual rule builder that generates JSON configuration automatically. No more hand-editing config files!

Response Templates

Create reusable response templates for common scenarios:

  • Payment declined: Standard response for testing declined transactions
  • Rate limited: 429 response with retry headers
  • Service unavailable: 503 with maintenance message

Migration Guide

Existing rules continue to work without changes. If you want to take advantage of new features, check out our migration guide.

What's Next

We're already working on:

  • Request mutation: Modify outgoing requests, not just responses
  • Webhooks: Trigger actions when rules match
  • Analytics: See which rules are being triggered and how often

Try Mutation Rules v2 today or read the docs.

Share this article

Ready to transform your API testing?

Join thousands of developers who ship with confidence using Stage.