Skip to content

Webhook Handling ​

FAST dispatches HMAC-SHA256 signed webhooks for all state changes. Your sportsbook must expose an HTTPS endpoint to receive these events.

Requirements ​

Your webhook endpoint must:

  • Accept POST requests with a JSON body
  • Return a 2xx status within 5 seconds (see Timeouts)
  • Verify the HMAC-SHA256 signature in the X-Webhook-Signature header

Payload Structure ​

json
{
  "eventId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "eventType": "challenge.completed",
  "userId": "user-001",
  "timestamp": "2026-01-15T10:00:00.000Z",
  "data": {
    "challengeId": "uuid",
    "finalBalance": 105.50
  }
}

Signature Verification ​

FAST signs the exact request body bytes with your tenant's webhook secret using HMAC-SHA256. The hex-encoded signature is sent in the X-Webhook-Signature header. The secret is a 64-character hex string; use it as-is as the HMAC key (do not hex-decode it).

Always verify the signature before processing the event:

  • HMAC the raw body as received. Do not parse and re-serialise it with JSON.stringify(req.body): key order and number formatting can differ from what FAST sent (retries in particular are re-serialised from storage), and the signature will not match.
  • Use a constant-time comparison, and check the lengths first: timingSafeEqual throws on buffers of different length.
  • During a secret rotation a second header, X-Webhook-Signature-Previous, carries the signature made with the old secret. Accept the delivery if either header matches a secret you hold (see Rotating the secret).

Every delivery, first attempt and retries alike, also carries:

HeaderValue
X-Webhook-SignatureHMAC-SHA256 of the body with your current secret, hex
X-Webhook-Signature-PreviousThe same with your previous secret; only for 48 hours after a rotation
X-Event-IdThe event's eventId, the same on every attempt
User-AgentFAST-Webhook/1.0
Content-Typeapplication/json

Node.js Example ​

javascript
const crypto = require("crypto");
const express = require("express");
const app = express();

const WEBHOOK_SECRET = process.env.FAST_WEBHOOK_SECRET;

function verifySignature(rawBody, signature) {
  const expected = Buffer.from(
    crypto.createHmac("sha256", WEBHOOK_SECRET).update(rawBody).digest("hex")
  );
  const received = Buffer.from(String(signature));
  return (
    received.length === expected.length &&
    crypto.timingSafeEqual(received, expected)
  );
}

// express.raw keeps the body as the exact bytes FAST signed
app.post("/webhooks/fast", express.raw({ type: "application/json" }), (req, res) => {
  const signature = req.headers["x-webhook-signature"];

  if (!signature || !verifySignature(req.body, signature)) {
    return res.status(401).send("Invalid signature");
  }

  const { eventId, eventType, userId, data } = JSON.parse(req.body.toString("utf8"));

  switch (eventType) {
    case "challenge.activated":
      // New challenge started - show challenge UI to user
      break;
    case "challenge.passed":
      // Challenge passed - prompt the user to continue or refund their own stake
      break;
    case "challenge.completed":
      // User continued - Reward Account created, enable funded features
      break;
    case "challenge.failed":
      // User failed - notify and allow re-purchase (own stake lost, bonus voided)
      break;
    case "challenge.cancelled":
      // User cancelled, no refund (data.ownStakeForfeited, data.bonusVoided)
      break;
    case "challenge.expiring_soon":
      // Less than 24 hours left (data.hoursRemaining): a good moment to nudge the user
      break;
    case "challenge.stake_refunded":
      // User exited after passing - refund only their own stake (data.ownStake)
      break;
    case "challenge.bonus_voided":
      // Bonus voided (on refund) - remove any bonus display
      break;
    case "funded_account.activated":
      // Reward Account created - enable funded features
      break;
    case "funded_account.revoked":
      // Funded account ended: remove access. data.reason says why (total drawdown,
      // cancellation, admin); data.finalBalance is what was on it.
      break;
    case "funded_account.inactivity_warning":
      // The account closes for inactivity at data.closesAt unless the user is
      // active before then. Sent 7 days and 1 day before (data.daysLeft).
      break;
    case "funded_account.closing":
      // Lifetime over or inactive (data.reason: 'expired' | 'inactivity'). No new
      // tickets; open ones settle, then the profit left is paid in a final payout.
      break;
    case "funded_account.closed":
      // A closing account closed with no profit to pay (data.finalBalance,
      // data.forfeitedProfit, data.debtWrittenOff). Remove access.
      break;
    case "funded_account.payout_debt":
      // A void after a payout took the balance below the funded amount
      // (data.payoutDebt). Nothing to claw back: later profit repays it first.
      break;
    case "funded_account.payout_requested":
      // A payout request is waiting for your decision (data.payoutRequestId,
      // data.amount = user's share, data.grossAmount = what leaves the balance,
      // data.isMandatory, data.isFinal). Betting is frozen until you decide.
      break;
    case "funded_account.payout_rejected":
      // The request was rejected: by you (data.reason = your text or null), because
      // the account ended ('account_closed'), or because a void took the profit
      // back before you confirmed ('profit_changed'). No money moved.
      break;
    case "funded_account.payout":
      // Payout executed - record in your system.
      // data.grossAmount = gross profit taken off the balance;
      // data.userPayout = the user's split of it; data.ownStakeReturned = own stake returned
      // (non-zero only on the first payout); data.rewardBonus = payout bonus reward paid on top;
      // data.totalPayout = userPayout + ownStakeReturned + rewardBonus.
      // data.accountClosed = true when the last allowed payout, or the final payout
      // of a closing account, ends the account.
      break;
    case "funded_account.stake_refunded":
      // Own stake refunded during the funded phase - refund data.ownStake
      break;
    case "cooldown.triggered":
      // Session stop hit: block betting UI until data.expiresAt
      break;
    case "cooldown.lifted":
      // Cooldown ended - re-enable betting UI
      break;
    case "bet.validation_result":
      // Bet validated - update bet status
      break;
  }

  // Return 200 immediately - process business logic async
  res.status(200).send("OK");
});

app.listen(3000);

Rotating the secret ​

POST /v1/admin/webhooks/rotate-secret (or Settings, Webhook, Rotate in the backoffice) returns a new secret once. For the next 48 hours FAST signs every delivery twice: with the new secret in X-Webhook-Signature and with the old one in X-Webhook-Signature-Previous. After 48 hours only the new secret signs.

So you can rotate first and deploy the new secret any time inside the window, with no failed deliveries:

  1. Rotate and store the new secret next to the old one.
  2. Let your handler accept a match of either secret against either header.
  3. Within 48 hours, remove the old secret.

The SDK does this for you:

javascript
import { verifyWebhookRequest } from "@fundedfast/sdk/webhooks";

const ok = await verifyWebhookRequest(rawBody, req.headers, [
  process.env.FAST_WEBHOOK_SECRET,      // new
  process.env.FAST_WEBHOOK_SECRET_OLD,  // old, until the window closes
]);
if (!ok) return res.status(401).send("Invalid signature");

Rotating again inside the window replaces the previous secret: only the secret you had just before the latest rotation keeps working.

Event Types ​

EventTrigger
challenge.activatedNew challenge purchased
challenge.passedChallenge passed; user must choose continue or refund
challenge.completedUser continued; Reward Account created
challenge.failedChallenge expired, total drawdown reached, or not enough active days
challenge.cancelledUser cancelled an active or passed challenge; no refund
challenge.expiring_soonChallenge expires within 24 hours; sent once
challenge.stake_refundedUser exited after passing; own stake to be refunded by the operator
challenge.bonus_voidedBonus voided (on refund)
funded_account.activatedReward Account created after the user continues
funded_account.revokedFunded account ended (total drawdown, cancellation or by the operator). Lifetime and inactivity never revoke: they close the account. Includes reason and finalBalance.
funded_account.inactivity_warningThe account closes for inactivity soon: sent 7 days and 1 day before. Includes closesAt, daysLeft, inactivityDays.
funded_account.closingThe account started closing: lifetime over or inactive (reason: expired or inactivity). No new tickets; open ones settle, then the profit left is paid in a final payout.
funded_account.payout_debtA void after a payout took the balance below the funded amount. Includes payoutDebt, debtAdded, reversedAmount, balance. No payout until later profit repays it; written off if the account ends first.
funded_account.closedA closing account closed with no profit to pay. Includes reason, finalBalance, forfeitedProfit, debtWrittenOff. With profit to pay, the final payout's funded_account.payout with accountClosed: true ends it instead.
funded_account.payout_requestedA payout request is waiting for the operator's decision; betting is frozen until it is decided. Includes payoutRequestId, amount (the user's share), grossAmount, operatorShare, isFinal, isMandatory.
funded_account.payout_rejectedA pending request was rejected: by the operator, because the account ended (reason: account_closed), or because the profit was no longer there when the operator confirmed (reason: profit_changed).
funded_account.payoutPayout executed. Includes grossAmount (taken off the balance), userPayout (the user's split of it), ownStakeReturned (own stake back on first payout, 0 after), rewardBonus (payout bonus reward, paid on top), totalPayout, operatorShare, accountClosed (true when the last allowed payout or the final payout of a closing account closed the account).
funded_account.stake_refundedOwn stake refunded during the funded phase
cooldown.triggeredSession stop hit: new tickets pause until expiresAt
cooldown.liftedCooldown period ended
bet.validation_resultBet validated (accepted or rejected)

The engagement modules (bonuses, missions, tournaments, loyalty, achievements, rewards) and self-exclusion send their own events. Webhook Events lists every event with its payload, and the signed daily export. Three points matter when you store them:

  • Mission events: missionId is the user's enrolment and missionTemplateId is the mission you created. A repeatable mission gives each attempt its own missionId, so key your records on missionId. mission.completed carries the granted rewardId and rewardValue (EUR for money types), or null and 0 when no reward was granted.
  • bonus.forfeited carries a reason: withdrawal or cancelled.
  • Tournament wide events (tournament.started, tournament.settled, tournament.cancelled) have an empty userId. tournament.started also comes straight from the create call when the start is already past.

Retry Logic ​

Every event is recorded in the same database transaction as the change it reports: if the change happened, the event will be delivered, even when FAST restarts a moment later or your hostname does not resolve at that moment. The first attempt follows right after; the URL and secret are read when each attempt is sent.

A delivery counts as failed on any non-2xx response, a network error, or a timeout. FAST makes at most 5 attempts per event, each delay measured from the previous attempt:

AttemptWhen
1Immediately
22 minutes later
38 minutes later
432 minutes later
52 hours later

Retries are picked up by a worker that runs once a minute, so each delay can run up to a minute long. Each tenant gets its own share of every run, so another operator's dead endpoint never delays your retries. A retry goes to the webhook URL configured now, signed with the secret configured now: if you moved your endpoint or rotated the secret after the first attempt, the retry follows.

After the fifth failed attempt the delivery is marked failed and moved to a dead letter queue. Failed deliveries are visible in the operator backoffice webhook log and can be retried manually, once at a time: a second retry of the same delivery while one is running answers 404, and a manual retry that fails again moves the delivery to the dead letter queue. A dead letter can be replayed once; replaying it again answers 409 already_replayed.

Timeouts ​

The first attempt waits up to 10 seconds for your response; retries wait only 5. The time covers the whole response, body included, and FAST reads at most 64 KB of it, so a short body such as ok is all you need. Redirects are not followed and count as a failure. Respond within 5 seconds so every attempt succeeds.

Deduplication ​

A retry carries the same eventId as the original delivery, in the body and in the X-Event-Id header. Deduplicate on it: store each eventId you have processed and acknowledge repeats with 200 without acting on them again. A manual replay from the dead letter queue also keeps the eventId.

Best Practices ​

  • Return 200 immediately. Queue heavy processing for async execution in your system.
  • Store the body's eventId and skip events you have already processed. FAST retries a delivery your endpoint processed but did not acknowledge with a 2xx in time.
  • Handle all event types, even if some require no action. Unknown event types should be logged and acknowledged with 200.
  • Store the raw payload for debugging before processing.

BLACKLINE CONSULTING d.o.o.