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:
- Navigate to your endpoint
- Open the Mock Responses section
- Click Add Rule
- 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
- Set matching conditions to control when the rule applies
- 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:
| Field | Example | Description |
|---|---|---|
method | POST | HTTP method |
path | /api/webhook | Request path |
headers.<name> | headers.content-type | Any request header |
query.<name> | query.id | Query string parameters |
body.<path> | body.status | JSON body fields (dot notation) |
Body fields support nested paths and array indices:
body.user.name— nested object fieldbody.items[0].id— array element
Operators
Comparison:
| Operator | Description | Example |
|---|---|---|
$eq | Equals | {"method": {"$eq": "POST"}} |
$neq | Not equals | {"method": {"$neq": "GET"}} |
$gt | Greater than | {"body.amount": {"$gt": 100}} |
$gte | Greater than or equal | {"body.priority": {"$gte": 5}} |
$lt | Less than | {"body.count": {"$lt": 10}} |
$lte | Less than or equal | {"body.count": {"$lte": 50}} |
String matching:
| Operator | Description | Example |
|---|---|---|
$contains | Contains substring | {"headers.content-type": {"$contains": "json"}} |
$startsWith | Starts with | {"path": {"$startsWith": "/api/"}} |
$endsWith | Ends with | {"body.email": {"$endsWith": "@example.com"}} |
$regex | Regular expression | {"body.email": {"$regex": "^[^@]+@example\\.com$"}} |
Array matching:
| Operator | Description | Example |
|---|---|---|
$in | Value in array | {"body.type": {"$in": ["order", "payment"]}} |
$nin | Value not in array | {"method": {"$nin": ["GET", "HEAD"]}} |
Special:
| Operator | Description | Example |
|---|---|---|
$exist | Field exists | {"body.optional_field": {"$exist": true}} |
$ref | Compare to another field | {"body.user_id": {"$ref": "headers.x-user-id"}} |
Logical:
| Operator | Description |
|---|---|
$and | All conditions must match |
$or | Any condition must match |
$not | Negation |
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