Endpoint Pipeline

Process webhooks through middleware steps before delivery, and route them to multiple destinations with conditional logic.

How It Works

Each endpoint can have a middleware pipeline and routing rules. When a webhook arrives:

  1. The webhook passes through each middleware step in order
  2. Filters may block the webhook, transforms modify headers or body, delays add latency, and deduplication prevents duplicate deliveries
  3. The processed webhook is routed based on the endpoint's routing mode and rules

Middleware Types

TypePurposeConfig Example
filterBlock webhooks based on conditions{"field": "headers.X-Type", "operator": "equals", "value": "test"}
transform_headersModify HTTP headers before delivery{"set": {"X-Auth": "token"}, "remove": ["X-Debug"]}
transform_bodyModify JSON payload content{"set": {"source": "hookwatch"}, "remove": ["debug_info"]}
delayAdd latency before delivery{"seconds": 5}
deduplicatePrevent duplicate deliveries{"key": "headers.X-Idempotency-Key", "ttl": 3600}

The Middleware Object

Json

Properties

FieldTypeDescription
idstringUnique identifier
endpoint_idstringParent endpoint ID
typestringMiddleware type: filter, transform_headers, transform_body, delay, or deduplicate
namestringHuman-readable name
configobjectType-specific configuration (see below)
sort_ordernumberExecution order (lower runs first)
is_activebooleanWhether the middleware is enabled

Middleware API

Base URL

https://api.hookwatch.dev/v1/webhook/endpoints/:endpoint_id/middlewares

Create Middleware

POST /v1/webhook/endpoints/:endpoint_id/middlewares

Request Body

FieldTypeRequiredDescription
typestringYesMiddleware type: filter, transform_headers, transform_body, delay, or deduplicate
namestringYesName for the middleware
configobjectYesType-specific configuration
is_activebooleanNoEnable/disable (default: true)
curl

List Middlewares

Retrieve all middlewares for an endpoint, ordered by sort_order.

GET /v1/webhook/endpoints/:endpoint_id/middlewares

Update Middleware

Update a middleware's type, name, config, or active status.

PUT /v1/webhook/endpoints/:endpoint_id/middlewares/:middleware_id

Delete Middleware

DELETE /v1/webhook/endpoints/:endpoint_id/middlewares/:middleware_id

Reorder Middlewares

Change the execution order by providing the middleware IDs in the desired sequence.

PUT /v1/webhook/endpoints/:endpoint_id/middlewares/reorder
curl

Test Pipeline

Dry-run a sample payload through all active middlewares to see how each step processes it.

POST /v1/webhook/endpoints/:endpoint_id/middlewares/test
curl

Response

Json

Routing Rules

Routing rules let you fan out webhooks to multiple destinations with conditional logic. Each rule can match on headers, body fields, or HTTP method.

Routing Modes

ModeBehavior
singleDeliver to the endpoint's primary destination only (default)
first_matchEvaluate rules in order, deliver to the first matching rule
all_matchDeliver to all rules whose conditions match
broadcastDeliver to all rules regardless of conditions
curl

The Routing Rule Object

Json

Properties

FieldTypeDescription
idstringUnique identifier
endpoint_idstringParent endpoint ID
namestringHuman-readable name
destination_urlstringURL to deliver the webhook to
condition_sourcestringWhere to evaluate: header, body, or method
condition_fieldstringField to check (header name or JSONPath for body)
condition_operatorstringComparison: equals, not_equals, contains, matches, or exists
condition_valuestringValue to compare against
retry_configobjectPer-rule retry configuration
headers_overrideobjectHeaders to add/override on delivery
transform_bodystringBody transformation template
sort_ordernumberEvaluation order (lower runs first)
is_activebooleanWhether the rule is enabled

Routing Rules API

Base URL

https://api.hookwatch.dev/v1/webhook/endpoints/:endpoint_id/routing-rules

Create Routing Rule

POST /v1/webhook/endpoints/:endpoint_id/routing-rules

Request Body

FieldTypeRequiredDescription
namestringYesName for the routing rule
destination_urlstringYesDestination URL for delivery
condition_sourcestringNoWhere to evaluate: header, body, or method
condition_fieldstringNoField to check (header name or JSONPath)
condition_operatorstringNoComparison operator
condition_valuestringNoValue to compare against
retry_configobjectNoCustom retry configuration
headers_overrideobjectNoHeaders to add/override on delivery
transform_bodystringNoBody transformation template
is_activebooleanYesEnable/disable the rule
curl

List Routing Rules

GET /v1/webhook/endpoints/:endpoint_id/routing-rules

Update Routing Rule

PUT /v1/webhook/endpoints/:endpoint_id/routing-rules/:rule_id

Delete Routing Rule

DELETE /v1/webhook/endpoints/:endpoint_id/routing-rules/:rule_id

Set Routing Mode

Change how webhooks are routed for this endpoint.

PUT /v1/webhook/endpoints/:endpoint_id/routing-mode

Test Routing Rules

Dry-run a sample payload against routing rules to see which destinations would be matched.

POST /v1/webhook/endpoints/:endpoint_id/routing-rules/test

Condition Operators

OperatorSourceDescription
equalsheader, body, methodExact string match
not_equalsheader, body, methodNot equal to value
containsheader, bodySubstring match
matchesheader, bodyRegular expression match
existsheader, bodyField is present (value ignored)

Body Conditions

When condition_source is body, the condition_field uses JSONPath syntax (e.g., $.event_type, $.data.customer.id).

Error Codes

StatusErrorDescription
400Bad RequestInvalid middleware type, missing required fields
401UnauthorizedInvalid or missing access token
404Not FoundEndpoint or middleware/rule not found
500Server ErrorInternal server error

Related