Filtering & Routing Rules

Learn how to filter webhooks based on JSON body fields, query parameters, and HTTP request headers.

Why Filter Webhooks?

Services like Stripe or GitHub can send dozens of events per second, but your billing microservice might only care about invoice.payment_succeeded and customer.subscription.deleted.

Filtering at the gateway level keeps downstream application logs clean and avoids wasteful database load.

Filter Syntax

Bunnylynk filters support JSONPath comparisons, regex matching, and boolean combinations (AND, OR, NOT).

Example 1: Match Specific Event Types

{
  "filter": {
    "body.type": {
      "$in": ["payment_intent.succeeded", "charge.refunded"]
    }
  }
}

Example 2: Numeric & Boolean Conditions

Filter Stripe events with amount greater than $100:

{
  "filter": {
    "$and": [
      { "body.type": "payment_intent.succeeded" },
      { "body.data.object.amount": { "$gt": 10000 } }
    ]
  }
}

Example 3: Header Matching

Filter based on custom sender headers:

{
  "filter": {
    "headers.x-environment": { "$eq": "production" }
  }
}

Available Operators

OperatorMeaningExample
$eqEqual to{ "body.status": { "$eq": "active" } }
$neNot equal to{ "body.status": { "$ne": "pending" } }
$inIn array{ "body.event": { "$in": ["created", "updated"] } }
$gt, $gteGreater than (or equal){ "body.total": { "$gte": 50 } }
$lt, $lteLess than (or equal){ "body.retries": { "$lt": 3 } }
$regexRegular expression{ "body.email": { "$regex": ".*@company\\.com$" } }

Next: Learn about Payload Transformations.