MarketIntell

Webhooks Guide

Set up webhook endpoints, verify signatures, and handle alpha-signal events

Webhooks Guide

Webhooks let you receive real-time notifications when MarketIntell publishes new alpha signals. Each delivery is HMAC-signed so you can verify it actually came from us.

Today's surface: the only event type currently delivered is alpha_signals. Each delivery batches all signals from a single scan cycle that meet your min_impact threshold. Per-signal signal.confirmed, agent.alert, and portfolio.threshold events are roadmap items — not yet emitted.

Setting up a webhook endpoint

1. Build the receiver

Your endpoint must:

  • Accept POST requests
  • Return a 2xx status code within 10 seconds
  • Be reachable over HTTPS (no localhost, no private IP ranges — both are SSRF-blocked at registration and at dispatch)
// Express.js example
import express from "express";
import crypto from "crypto";

const WEBHOOK_SECRET = process.env.MARKETINTELL_WEBHOOK_SECRET!;

const app = express();
// Capture the raw body — HMAC must be computed over the exact bytes we send.
app.use(express.json({
  verify: (req: any, _res, buf) => {
    req.rawBody = buf.toString("utf8");
  },
}));

app.post("/webhooks/marketintell", (req: any, res) => {
  const signature = req.headers["x-webhook-signature"] as string;
  if (!signature || !verifySignature(req.rawBody, signature, WEBHOOK_SECRET)) {
    return res.status(401).json({ error: "Invalid signature" });
  }

  const { event, id: deliveryId, signals } = req.body;
  console.log(`[${deliveryId}] ${event}: ${signals.length} signals`);

  // Process asynchronously so we can ACK quickly
  processSignals(signals).catch(console.error);

  res.status(200).json({ received: true });
});

2. Register the webhook

curl -X POST https://api.marketintell.ai/v1/webhooks \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "url": "https://your-server.com/webhooks/marketintell",
    "events": ["alpha_signals"],
    "min_impact": "MEDIUM"
  }'

min_impact filters incoming signals — accepts LOW, MEDIUM (default), HIGH, or CRITICAL. Anything below your threshold is silently dropped before delivery.

3. Save the secret

The create response includes a secret field. This is the only time the full secret is returned in the create flow — store it immediately. If you lose it, fetch it again via GET /v1/webhooks/:id (owner-scoped — only the key that created the webhook can read its own secret).

{
  "success": true,
  "data": {
    "id": "wh_a1b2c3...",
    "url": "https://your-server.com/webhooks/marketintell",
    "events": ["alpha_signals"],
    "min_impact": "MEDIUM",
    "active": true,
    "created_at": "2026-04-22T13:58:00.000Z",
    "secret": "ec9f4a...a 64-char hex string..."
  }
}

Delivery payload

Every delivery is a JSON POST with the following shape:

{
  "event": "alpha_signals",
  "id": "37c1b2c5-9e1d-4f80-bb2c-7e1ad42cc5a2",
  "timestamp": "2026-04-22T13:58:00.000Z",
  "signals": [
    {
      "id": "sig_001",
      "headline": "Whale accumulation: 5,200 BTC moved to cold storage",
      "analysis": "Multiple large wallets transferred BTC off exchanges...",
      "sentiment": "bullish",
      "impact": "HIGH",
      "category": "whale",
      "tokens_affected": ["BTC"],
      "invalidation": "Inflows reverse within 24h"
    }
  ]
}

Headers

HeaderDescription
Content-TypeAlways application/json
X-Webhook-EventEvent name (alpha_signals today) for fast routing
X-Webhook-DeliveryUUID unique to this attempt — use it for receiver-side dedup
X-Webhook-SignatureHMAC-SHA256 of the raw request body as a 64-char hex string
User-AgentMarketIntell-Webhooks/1.0

Verifying signatures

Every delivery includes an X-Webhook-Signature header containing HMAC-SHA256(rawBody, secret) hex-encoded. Recompute the digest over the exact bytes you received and compare with constant-time equality.

Node.js

import crypto from "crypto";

function verifySignature(
  rawBody: string,
  signature: string,
  secret: string,
): boolean {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(rawBody)
    .digest("hex");

  // Both inputs must be the same length for timingSafeEqual.
  const a = Buffer.from(signature, "hex");
  const b = Buffer.from(expected, "hex");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Python

import hmac
import hashlib

def verify_signature(raw_body: bytes, signature: str, secret: str) -> bool:
    expected = hmac.new(
        secret.encode(),
        raw_body,
        hashlib.sha256,
    ).hexdigest()
    return hmac.compare_digest(signature, expected)

Always compute the HMAC over the raw request body bytes — re-serializing the parsed JSON will produce a different string and your verification will fail. Most frameworks (Express, FastAPI, Hono) require explicit raw-body capture.

Retry behaviour

Each delivery is attempted up to 4 times with backoff:

AttemptDelay before this attempt
1none — sent immediately
21 second
31.5 seconds
45 seconds

A delivery is considered failed when:

  • Your endpoint returns a 5xx or 429 (we keep retrying)
  • The request times out (10 second per-attempt limit)
  • The endpoint is unreachable (DNS / TCP failure)

A 4xx other than 429 is treated as a caller bug — we do not retry. Fix the endpoint and signals will keep flowing on the next scan cycle.

After 5 consecutive failed dispatch cycles (across signals, not retries), the webhook is automatically disabled. Re-enable it via DELETE /v1/webhooks/:id then POST /v1/webhooks to rotate the secret as well.

Inspecting delivery health

curl https://api.marketintell.ai/v1/webhooks \
  -H "X-API-Key: YOUR_API_KEY"

Each row includes last_triggered_at (last successful delivery) and last_attempt_at (last attempt regardless of outcome). When these diverge by more than your scan interval, dispatch is failing.

The list view never includes the secret — fetch a single webhook via GET /v1/webhooks/:id to recover it.

Best practices

  1. ACK fast, process async. Return 200 immediately; do the work in a queue.
  2. Dedup by X-Webhook-Delivery. Retries reuse the same id; a follow-up scan emits a fresh one.
  3. Always verify the signature. Skipping verification is the same as making your endpoint a public POST.
  4. Use HTTPS. HTTP URLs are rejected at registration.
  5. Rotate compromised secrets by deleting and re-creating the webhook.

On this page