Event Filtering
Route events to endpoints based on payload content using filter expressions.
Filter syntax
Section titled “Filter syntax”Filters use JSONPath-style expressions evaluated against the event payload:
{ "filter": [ { "field": "$.data.amount", "operator": "gte", "value": 1000 }, { "field": "$.data.currency", "operator": "eq", "value": "USD" } ]}All conditions must match (AND logic by default). An endpoint whose filter doesn’t match is skipped for that event. If that leaves no endpoint to deliver to (none subscribes to the event type, or every subscriber’s filter excludes the payload), POST /api/v1/events returns 400 NO_MATCHING_ENDPOINTS and no event is stored.
Operators
Section titled “Operators”| Operator | Description | Example |
|---|---|---|
eq | Equal | "$.status" eq "active" |
ne | Not equal | "$.type" ne "test" |
gt | Greater than | "$.amount" gt 100 |
gte | Greater or equal | "$.amount" gte 1000 |
lt | Less than | "$.priority" lt 5 |
lte | Less or equal | "$.retry_count" lte 3 |
contains | String contains | "$.email" contains "@company.com" |
startsWith | String starts with | "$.path" startsWith "/api/" |
endsWith | String ends with | "$.file" endsWith ".pdf" |
exists | Field exists | "$.metadata.tags" exists true |
regex | Regex match | "$.code" regex "^[A-Z]{3}$" |
Logical combinators
Section titled “Logical combinators”For complex filtering, use and, or, and not:
{ "filter": { "or": [ { "field": "$.data.amount", "operator": "gte", "value": 10000 }, { "and": [ { "field": "$.data.currency", "operator": "eq", "value": "USD" }, { "field": "$.data.priority", "operator": "eq", "value": "high" } ] } ] }}Nesting is supported up to 10 levels deep.
Example: Route high-value orders
Section titled “Example: Route high-value orders”curl -X POST https://app.mittr.io/api/v1/endpoints \ -H "X-API-Key: mtr_your_key" \ -H "Content-Type: application/json" \ -d '{ "url": "https://billing.example.com/webhooks", "eventTypes": ["order.created"], "filter": [ { "field": "$.data.amount", "operator": "gte", "value": 10000 } ] }'Only order.created events with data.amount >= 10000 are delivered to this endpoint.
Combined with fan-out
Section titled “Combined with fan-out”Filters work alongside event type subscriptions:
- An event is sent with
eventType: "order.created" - Mittr finds all endpoints subscribed to
order.created(ororder.*) - Each endpoint’s filter is evaluated against the payload
- Only matching endpoints receive the delivery
This allows fine-grained routing without duplicating events.