Filters API

Filters control which webhook events are forwarded through a route based on conditions applied to the payload.

Endpoints

MethodPathDescription
GET/api/filtersList filters
POST/api/filtersCreate filter
GET/api/filters/{id}Get filter
PATCH/api/filters/{id}Update filter
DELETE/api/filters/{id}Delete filter

Filter Object

{
  "id": "flt_abc123",
  "name": "Push Events Only",
  "description": "Only forward push events from GitHub",
  "conditions": [
    {
      "field": "headers.X-GitHub-Event",
      "operator": "equals",
      "value": "push"
    }
  ],
  "logic": "AND",
  "routeCount": 2,
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Condition Object

FieldTypeDescription
fieldstringJSONPath to the field in payload or headers (e.g., payload.action, headers.X-GitHub-Event)
operatorstringComparison operator (see below)
valuestringValue to compare against

Operators

OperatorDescriptionExample
equalsExact match"push"
not_equalsNot equal"delete"
containsString contains"release"
not_containsString does not contain"test"
starts_withString starts with"refs/heads/"
ends_withString ends with".json"
matchesRegex match"^v\\d+\\.\\d+"
existsField exists (value ignored)
not_existsField does not exist (value ignored)
gtGreater than (numeric)"100"
gteGreater than or equal (numeric)"100"
ltLess than (numeric)"50"
lteLess than or equal (numeric)"50"
inValue in comma-separated list"push,pull_request,release"
not_inValue not in comma-separated list"bot,automated"

Logic

ValueDescription
ANDAll conditions must match (default)
ORAny condition must match

List Filters

GET /api/filters

Query Parameters

ParameterTypeDescription
pagenumberPage number (default: 1)
pageSizenumberItems per page (default: 20, max: 100)
searchstringSearch by name

Example

curl
curl https://api.hookbase.app/api/filters \
  -H "Authorization: Bearer whr_your_api_key"

Response

{
  "data": [
    {
      "id": "flt_abc123",
      "name": "Push Events Only",
      "conditions": [
        {
          "field": "headers.X-GitHub-Event",
          "operator": "equals",
          "value": "push"
        }
      ],
      "logic": "AND",
      "routeCount": 2
    }
  ],
  "pagination": {
    "total": 3,
    "page": 1,
    "pageSize": 20
  }
}

Create Filter

POST /api/filters

Request Body

FieldTypeRequiredDescription
namestringYesDisplay name
conditionsarrayYesArray of condition objects
descriptionstringNoOptional description
logicstringNoAND or OR (default: AND)

Example

curl
curl -X POST https://api.hookbase.app/api/filters \
  -H "Authorization: Bearer whr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Push Events",
    "description": "Only forward push events to main branch",
    "conditions": [
      {
        "field": "headers.X-GitHub-Event",
        "operator": "equals",
        "value": "push"
      },
      {
        "field": "payload.ref",
        "operator": "equals",
        "value": "refs/heads/main"
      }
    ],
    "logic": "AND"
  }'

Response

{
  "id": "flt_new123",
  "name": "Production Push Events",
  "description": "Only forward push events to main branch",
  "conditions": [
    {
      "field": "headers.X-GitHub-Event",
      "operator": "equals",
      "value": "push"
    },
    {
      "field": "payload.ref",
      "operator": "equals",
      "value": "refs/heads/main"
    }
  ],
  "logic": "AND",
  "routeCount": 0,
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Get Filter

GET /api/filters/{id}

Example

curl
curl https://api.hookbase.app/api/filters/flt_abc123 \
  -H "Authorization: Bearer whr_your_api_key"

Response

Returns the full filter object.

Update Filter

PATCH /api/filters/{id}

Request Body

All fields are optional. Only provided fields are updated.

FieldTypeDescription
namestringDisplay name
conditionsarrayArray of condition objects (replaces existing)
descriptionstringOptional description
logicstringAND or OR

Example

curl
curl -X PATCH https://api.hookbase.app/api/filters/flt_abc123 \
  -H "Authorization: Bearer whr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "conditions": [
      {
        "field": "headers.X-GitHub-Event",
        "operator": "in",
        "value": "push,pull_request,release"
      }
    ]
  }'

Response

Returns the updated filter object.

Delete Filter

DELETE /api/filters/{id}

Warning

A filter cannot be deleted while it is assigned to active routes. Remove it from all routes first.

Example

curl
curl -X DELETE https://api.hookbase.app/api/filters/flt_abc123 \
  -H "Authorization: Bearer whr_your_api_key"

Response

204 No Content

Inline Filters vs Saved Filters

Routes support two approaches to filtering:

  1. Saved filters — Create a filter via this API and reference it by filterId in the route. Reusable across multiple routes.
  2. Inline filters — Define filterConditions and filterLogic directly on the route. Simpler for one-off conditions.
# Using a saved filter
curl -X POST .../routes \
  -d '{"name": "My Route", "sourceId": "src_1", "destinationIds": ["dst_1"], "filterId": "flt_abc123"}'
 
# Using inline conditions
curl -X POST .../routes \
  -d '{
    "name": "My Route",
    "sourceId": "src_1",
    "destinationIds": ["dst_1"],
    "filterConditions": [
      {"field": "headers.X-GitHub-Event", "operator": "equals", "value": "push"}
    ],
    "filterLogic": "AND"
  }'

Error Responses

400 Bad Request

Invalid condition:

{
  "error": "Bad Request",
  "message": "Invalid operator 'like'. Must be one of: equals, not_equals, contains, ...",
  "code": "INVALID_CONDITION"
}

409 Conflict

Filter in use:

{
  "error": "Conflict",
  "message": "Filter is assigned to 2 active routes",
  "code": "RESOURCE_IN_USE"
}