Inbound Gateways
Verify Stripe, Shopify, GitHub, and KestrelMQ HMAC webhooks over raw bytes at POST /v1/inbound/:sourceSlug, pause forwarding into PAUSED state, and drain at maxRatePerSec.
Inbound Gateways place KestrelMQ in front of your internal webhook consumers. External providers send webhooks to POST /v1/inbound/:sourceSlug; KestrelMQ verifies upstream signatures against the raw request Buffer, persists an INBOUND event + delivery targeting targetUrl, absorbs deployment maintenance windows via pause / resume, and shapes downstream forwarding to maxRatePerSec.
Signature Verification Strategies (InboundProviderType)
InboundGatewayController captures request.rawBody before JSON parsing and verifies signatures in constant time (crypto.timingSafeEqual):
providerType | Required Headers | Verification Formula |
|---|---|---|
STRIPE | Stripe-Signature | Parses t=<unix_sec>,v1=<64-hex> (supports multiple v1= values), enforces 300s replay window, verifies HMAC-SHA256("${t}.${rawBody}", signingSecret). |
SHOPIFY | X-Shopify-Hmac-Sha256 | Verifies canonical 44-char Base64 HMAC-SHA256(rawBody, signingSecret). |
GITHUB | X-Hub-Signature-256 | Verifies sha256=<64-hex> HMAC-SHA256(rawBody, signingSecret). |
CUSTOM_HMAC | X-KestrelMQ-Timestamp + X-KestrelMQ-Signature | Enforces 300s replay tolerance and verifies v1=<64-hex> over HMAC-SHA256("${timestamp}.${rawBody}", signingSecret). |
NONE | None | Accepts unsigned public webhooks (signingSecret optional). |
Missing or invalid signatures are rejected at the edge with 401 Unauthorized (application/problem+json) before any database write.
Automatic Inbound Event Name Mapping
KestrelMQ derives events.event_name from incoming headers and body fields in the following priority order:
X-KestrelMQ-Eventheader (if present and whitespace-free).- GitHub header (
providerType === "GITHUB"):X-GitHub-Event: push→github.push. - Shopify header (
providerType === "SHOPIFY"):X-Shopify-Topic: orders/paid→shopify.orders.paid(/replaced with.). - JSON payload field:
payload.type(e.g. Stripeinvoice.payment_succeeded) orpayload.event. - Fallback:
inbound.<providerType.toLowerCase()>(e.g.inbound.stripe,inbound.custom_hmac).
Managing Inbound Sources (/v1/inbound-sources)
Inbound source CRUD endpoints require an operator Access JWT (OWNER or ADMIN; VIEWER allowed on GET) and the X-Workspace-Id header:
curl -s -X POST http://localhost:3000/v1/inbound-sources \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "X-Workspace-Id: ${WORKSPACE_ID}" \
-H "Content-Type: application/json" \
-d '{
"name": "Stripe Billing Webhooks",
"sourceSlug": "stripe-billing-prod",
"providerType": "STRIPE",
"signingSecret": "whsec_upstream_stripe_secret",
"targetUrl": "https://api.acme.io/internal/webhooks/stripe",
"maxRatePerSec": 10
}'signingSecretis encrypted at rest withAES-256-GCM(encrypted_signing_secret,iv,auth_tag); responses returnhasSigningSecret: truewithout exposing plaintext.- If
sourceSlugis omitted, KestrelMQ auto-generates a unique slug (<slugified-name>-<8-hex>). maxRatePerSec(1–10000, default10) limits downstream forwarding rate per second via Redis sliding-window checks (ratelimit:inbound:egress:<sourceId>).
Receiving Upstream Webhooks (POST /v1/inbound/:sourceSlug)
Upstream providers post directly to the public receiver endpoint, which responds with 200 OK:
{
"received": true,
"eventId": "c4b2f810-9e31-4d7a-8b15-02f9a6e31c48",
"deliveryId": "9bafef5c-41d2-4e89-9a0b-3c14d78e02f1",
"status": "PENDING",
"buffered": false
}When KestrelMQ forwards the verified payload to targetUrl, it signs the outbound request with your workspace's webhookSigningSecret (X-KestrelMQ-Timestamp + X-KestrelMQ-Signature: v1=...).
Pause Buffering & Rate-Limited Drain
During downstream deploys or database migrations, pause forwarding without losing upstream webhooks:
curl -s -X POST \
http://localhost:3000/v1/inbound-sources/${SOURCE_ID}/pause \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "X-Workspace-Id: ${WORKSPACE_ID}"curl -s -X POST \
http://localhost:3000/v1/inbound-sources/${SOURCE_ID}/resume \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "X-Workspace-Id: ${WORKSPACE_ID}"- While paused (
isPaused: true):POST /v1/inbound/:sourceSlugcontinues verifying HMAC signatures, persists deliveries withstatus: "PAUSED"andbuffered: true, and returns200 OKso Stripe/Shopify/GitHub never disable your webhook endpoint. - On resume (
POST /v1/inbound-sources/:id/resume): Transitions bufferedPAUSEDdeliveries back toPENDING, returns{ source, resumedDeliveriesCount }, and drains them intotargetUrlsmoothly atmaxRatePerSec(excess jobs yield via BullMQmoveToDelayedwithout failing attempts).
Pause or resume from AI agents
Operators using Claude Code or Cursor can toggle pause/resume with an API key via the toggle_inbound_source MCP tool ({ "sourceId": "<uuid>", "action": "pause" | "resume" }).