Skip to main content

Mock Response Rules

Mock response rules let you configure what your debug endpoint returns to the webhook sender. By default, endpoints return a 202 Accepted with an empty body. With mock rules, you can return custom status codes, headers, and bodies based on request attributes.

Why use mock responses?

  • Test error handling — return 4xx or 5xx status codes to see how your webhook provider handles failures
  • Simulate retries — return errors intermittently to test retry logic
  • Return expected responses — some providers require specific response formats to acknowledge receipt
  • Simulate latency — add response delays to test timeout behavior
  • Develop locally — mock API responses while building your integration

Creating a mock response rule

From the endpoint detail view in the dashboard:

  1. Navigate to your endpoint
  2. Open the Mock Responses section
  3. Click Add Rule
  4. Configure the rule:
    • Name — a descriptive label for the rule
    • Priority — higher priority rules are evaluated first (default: 0)
    • Status code — HTTP status code to return (100-599, default: 200)
    • Response headers — custom headers to include in the response
    • Response body — the body content to return (max 10,000 characters)
    • Response delay — simulated latency in milliseconds (0-10,000ms)
    • Enabled — toggle the rule on/off without deleting it
  5. Set matching conditions to control when the rule applies
  6. Save the rule

Default endpoint response

If no mock rule matches, the endpoint returns its default response:

  • Status code: 202 Accepted (configurable per endpoint)
  • Body: empty (configurable per endpoint)

You can change the default response in the endpoint settings without creating a mock rule.

Matching conditions

Rules use a filter engine that supports complex conditional matching against request data.

Available fields

Conditions can match against these request properties:

FieldExampleDescription
methodPOSTHTTP method
path/api/webhookRequest path
headers.<name>headers.content-typeAny request header
query.<name>query.idQuery string parameters
body.<path>body.statusJSON body fields (dot notation)

Body fields support nested paths and array indices:

  • body.user.name — nested object field
  • body.items[0].id — array element

Operators

Comparison:

OperatorDescriptionExample
$eqEquals{"method": {"$eq": "POST"}}
$neqNot equals{"method": {"$neq": "GET"}}
$gtGreater than{"body.amount": {"$gt": 100}}
$gteGreater than or equal{"body.priority": {"$gte": 5}}
$ltLess than{"body.count": {"$lt": 10}}
$lteLess than or equal{"body.count": {"$lte": 50}}

String matching:

OperatorDescriptionExample
$containsContains substring{"headers.content-type": {"$contains": "json"}}
$startsWithStarts with{"path": {"$startsWith": "/api/"}}
$endsWithEnds with{"body.email": {"$endsWith": "@example.com"}}
$regexRegular expression{"body.email": {"$regex": "^[^@]+@example\\.com$"}}

Array matching:

OperatorDescriptionExample
$inValue in array{"body.type": {"$in": ["order", "payment"]}}
$ninValue not in array{"method": {"$nin": ["GET", "HEAD"]}}

Special:

OperatorDescriptionExample
$existField exists{"body.optional_field": {"$exist": true}}
$refCompare to another field{"body.user_id": {"$ref": "headers.x-user-id"}}

Logical:

OperatorDescription
$andAll conditions must match
$orAny condition must match
$notNegation

Condition examples

Match POST requests only:

[{"method": {"$eq": "POST"}}]

Match requests with a specific event type:

[{"body.type": {"$in": ["order.created", "order.updated"]}}]

Complex conditions with logical operators:

[
{
"$and": [
{"method": {"$eq": "POST"}},
{
"$or": [
{"body.type": {"$eq": "urgent"}},
{"body.priority": {"$gte": 5}}
]
}
]
}
]

Priority and evaluation

  • Rules are evaluated by priority (highest number first)
  • When multiple rules match, the highest-priority match wins
  • If no rule matches, the endpoint's default response is used
  • Disabled rules are skipped

Example: Stripe webhook acknowledgment

Name: "Stripe OK" Conditions: [{"headers.user-agent": {"$contains": "Stripe"}}] Status code: 200 Body: {"received": true}

Example: Simulating latency

Name: "Slow response" Status code: 200 Response delay: 3000 (3 seconds) Body: {"status": "ok"}

Notes

  • Mock responses don't affect request capture — the request is still recorded regardless of the response
  • The response body is limited to 10,000 characters
  • Response delay is capped at 10 seconds
  • Rules can be enabled/disabled without deleting them