ReHook Documentation

ReHook is a powerful webhook middleware that routes, transforms, and monitors webhook traffic from a single endpoint.

🎯
Auto-Detection

Automatically detect webhook schema and event types

🔄
Fan-Out

Send one webhook to multiple destinations

Transforms

Modify payloads with JavaScript

🔁
Retries

Exponential backoff and dead-letter queues

Quick Start

Get up and running in 5 minutes:

1

Create a Project

Navigate to your dashboard and create a new project to organize your webhooks.

2

Create a Source

A source provides a unique webhook URL. Point your integrations to this URL.

https://your-rehook.com/api/v1/ingest/abc123
3

Add Destinations

Configure where your webhook events should be forwarded. Each destination has its own URL, authentication, and settings.

4

Enable Forwarding

Toggle forwarding ON and your webhooks will start flowing!

Core Concepts

📥 Sources

A source is an inbound webhook endpoint. Each source gets a unique URL that accepts webhook requests from external services like Stripe, GitHub, or Shopify.

📤 Destinations

A destination is where events are forwarded to. Configure the target URL, authentication method, custom headers, rate limits, and retry policies.

🔄 Transforms

Transforms allow you to modify the webhook payload using JavaScript before forwarding. Filter events, reshape data, or add custom fields.

🎯 Triggers

Triggers define when events should be forwarded based on conditions like event type, payload content, or custom JavaScript expressions.

Sources Configuration

SettingDescriptionDefault
nameDisplay name for the sourceRequired
slugURL-friendly identifierAuto-generated
enabledWhether the source accepts eventstrue
forwarding_enabledWhether events are forwarded to destinationsfalse

Destinations Configuration

SettingDescriptionDefault
urlTarget URL for forwardingRequired
auth_policy_idAuthentication policy to usenull
rate_limitMax requests per second (Hz)null (unlimited)
timeout_msRequest timeout in milliseconds30000
retry_countMax retry attempts3
custom_headersAdditional headers to send{}

Transforms

Transforms use JavaScript to modify the payload. The function receives the event and must return the modified payload or null to skip.

// Example: Filter and reshape Stripe events
function transform(event) {
  // Skip non-payment events
  if (!event.type.startsWith('payment')) {
    return null;
  }
  
  // Reshape the payload
  return {
    type: event.type,
    amount: event.data.object.amount,
    currency: event.data.object.currency,
    customer: event.data.object.customer,
    timestamp: new Date().toISOString()
  };
}

Available Variables

VariableDescription
eventThe original webhook payload
headersRequest headers object
sourceSource metadata

Triggers

Triggers control which events are forwarded to a destination.

Trigger Types

TypeDescriptionExample
event_typeMatch specific event typespayment.succeeded
field_matchMatch payload field valuesdata.status = "active"
javascriptCustom JS expressionevent.amount > 100

API Authentication

All API requests require authentication using an API key.

# Include in request header
Authorization: Bearer rh_sk_xxxxxxxxxxxx

# Or as query parameter
?api_key=rh_sk_xxxxxxxxxxxx

API Key Scopes

ScopePermissions
events:readView events and deliveries
events:writeCreate events, replay, resend
sources:readView sources and destinations
sources:writeCreate and modify sources
adminFull access to all resources

Events API

GET/api/v1/events

List all events with optional filters

GET/api/v1/events/:id

Get event details with delivery history

POST/api/v1/events/:id/replay

Replay an event to all destinations

POST/api/v1/events/:id/retry-failed

Retry only failed deliveries for an event

Deliveries API

GET/api/v1/deliveries/:id

Get delivery details and response

POST/api/v1/deliveries/:id/resend

Resend a specific delivery

Sources API

GET/api/v1/sources

List all sources

POST/api/v1/sources

Create a new source

PUT/api/v1/sources/:id

Update a source

DELETE/api/v1/sources/:id

Delete a source

Rate Limiting

ReHook uses a token bucket algorithm for rate limiting per destination.

How it works: If a destination has a rate limit of 10 requests/second, ReHook will queue and deliver events at that rate, using exponential backoff when the destination is overloaded.

Configuration

  • rate_limit: Requests per second (e.g., 10 = 10 req/s)
  • Backoff: 1s → 2s → 4s → 8s → ... up to 60s
  • Circuit Breaker: Opens after 10 consecutive failures, 1 min cooldown

Retries & Dead Letter Queue

Retry Strategy

Failed deliveries are automatically retried with exponential backoff:

Attempt 1: Immediate
Attempt 2: After 1 second
Attempt 3: After 2 seconds
Attempt 4: After 4 seconds
... up to max_retries (default: 3)

Dead Letter Queue (DLQ)

Events that fail all retry attempts are moved to the DLQ. From the DLQ you can:

  • Inspect the failure reason and response
  • Replay the event to all destinations
  • Retry only failed deliveries
  • Resolve (acknowledge) the error

Event Status Flow

StatusDescription
pendingWaiting to be processed
processingCurrently being delivered
retryingDelivery failed, retrying
deliveredAll destinations succeeded
partialSome destinations succeeded, some failed
failedAll destinations failed
dlqMoved to Dead Letter Queue

Security

Authentication Methods

TypeDescriptionUse Case
hmacHMAC signature verificationStripe, GitHub webhooks
bearerBearer token in Authorization headerOAuth APIs
api_keyAPI key in header or querySimple APIs
basicHTTP Basic AuthenticationLegacy systems

Best Practices

  • Rotate API keys regularly
  • Use scoped keys with minimal permissions
  • Enable HMAC verification for incoming webhooks
  • Use HTTPS for all destination URLs

Error Handling

Common Error Codes

CodeDescriptionSolution
DESTINATION_TIMEOUTRequest exceeded timeoutIncrease timeout_ms or optimize destination
RATE_LIMITEDDestination rate limit exceededAutomatic retry with backoff
CONNECTION_REFUSEDCannot connect to destinationCheck destination URL and firewall
AUTH_FAILEDAuthentication rejectedVerify auth policy configuration
TRANSFORM_ERRORJavaScript transform failedCheck transform syntax
MAX_RETRIES_EXCEEDEDAll retry attempts failedCheck DLQ and fix destination
Tip: Enable notifications in Settings to receive alerts when deliveries fail or events are moved to the DLQ.