Skip to content

Real-Time Events (SSE) ​

FAST provides a Server-Sent Events stream for real-time notifications. Your frontend receives instant updates when challenges complete, bets are validated, cooldowns trigger, etc.

Authentication ​

EventSource (SSE) cannot send HTTP headers. FAST uses HMAC-signed tokens to authenticate SSE connections without exposing API keys in URLs.

Token endpoint ​

Call it from your backend with your server key:

POST /v1/sse/token
X-API-Key: key-your-server-key
Content-Type: application/json

{ "userId": "player-42" }

Response:

json
{
  "token": "eyJ0aWQiOiJ...",
  "streamToken": "eyJ0aWQiOiJ...",
  "expiresAt": "2026-06-07T15:00:00.000Z",
  "ttl": 3600,
  "userId": "player-42"
}

Who may mint a token:

CallerAllowed
Server key (key-...)Any user of your tenant
A widget user token (X-User-Token)Only a fresh token for its own userId, and only up to 24 hours after the first token of that chain was minted (403 token_chain_expired after that: mint a new one from your backend)
Public widget key (pk_...) aloneStaging tenants only. On a production tenant it is refused with 403 forbidden

token is the user token the widget takes as data-user-token. It authorises the player's actions, so it never goes in a URL. streamToken opens the event stream and nothing else.

Connect to SSE ​

GET /v1/events?token=<streamToken>&userId=player-42

No API key in URL. The stream token is HMAC-signed with a server-side secret and contains:

  • Tenant ID (which operator)
  • User ID (scoped to one player)
  • Expiry timestamp
  • The stream scope: the user token is refused on the stream, and the stream token is refused as X-User-Token

Limits: 5 streams per user (a sixth gets an error event with too_many_connections and is closed). Rotating your API keys also rotates the token secret, which revokes every user and stream token.

Token refresh ​

Tokens expire after 1 hour (3600 seconds). The ttl field tells you the lifetime. The stream ends when its token expires, after a token_expired event, so reconnect with a fresh token before expiry or on that event.

Recommended: refresh at 80% of TTL (about every 48 minutes). The widget renews its own token; a chain of self refreshes ends 24 hours after your backend minted the first token.

Events ​

On connect the stream sends a retry: line (the reconnect delay, 1 to 6 seconds, different per connection) and an empty connected event. Refetch progress whenever connected arrives, since a reconnect can miss events.

A stream opened with a user token carries only events about that user. Most webhook event types are mirrored, plus bet.settled. The payloads are smaller than the webhook ones, so treat an event as a signal to refetch progress. Every payload below also carries userId.

EventWhenPayload
challenge.activatedNew challenge purchased and startedchallengeId
challenge.passedChallenge target reached; user must choose continue or refundchallengeId, programBalance, refundableOwnStake
challenge.completedUser continued after passing; Reward Account createdchallengeId, finalBalance, fundedAccountBalance
challenge.failedChallenge failed (total drawdown, expiry, insufficient active days)challengeId, reason
challenge.cancelledUser cancelled the challengechallengeId, ownStakeForfeited, bonusVoided
challenge.stake_refundedUser exited after passing; own stake to be refundedchallengeId, ownStake, bonusAmount
funded_account.activatedFunded account created after the user continuedfundedAccountId
funded_account.payout_requestedA payout request is waiting for the operatorfundedAccountId, payoutRequestId
funded_account.payout_rejectedA pending payout request was rejectedfundedAccountId, payoutRequestId
funded_account.payoutPayout executedthe full webhook payload
funded_account.revokedFunded account ended (total drawdown, cancellation, admin)fundedAccountId
funded_account.inactivity_warningFunded account closes for inactivity soon (7 days and 1 day before)fundedAccountId, closesAt
funded_account.closingFunded account started closing (lifetime over or inactive)fundedAccountId, reason
funded_account.closedClosing funded account closed with no profit to paythe full webhook payload
funded_account.payout_debtA void after a payout left a debt that later profit repaysfundedAccountId, payoutDebt
funded_account.stake_refundedOwn stake refunded during the funded phasefundedAccountId, ownStake
bet.validation_resultA placed bet was accepted or rejectedbetId, status, reasonCodes
bet.settledBet settlement processed (SSE only, no webhook)betId, outcome (won, lost or void)
cooldown.triggeredSession stop hit: new tickets pausedreason, expiresAt
cooldown.liftedPause endednone
reward.grantedReward grantedrewardId, rewardType, rewardValue
bonus.activatedWagering bonus startedbonusId
bonus.completedWagering requirement metbonusId
mission.completedMission completedmissionId, missionName
tournament.user_invitedUser invited to a tournamenttournamentId, tournamentName
loyalty.tier_upgradedUser moved up a loyalty tiertier
user.self_excludedUser self-excludedreason
user.self_exclusion_liftedExclusion liftedreinstatedBy

challenge.bonus_voided, challenge.expiring_soon, reward.applied, reward.expired, achievement.earned and the other bonus, mission, tournament and loyalty events are webhook only. tournament.started and tournament.settled concern no single user, so they reach only a tenant wide stream (the backoffice), never a user stream.

Implementation examples ​

Browser (vanilla JS) ​

javascript
// 1. Fetch token from your backend (never expose API key in frontend)
const res = await fetch('/api/fast/user-token', { method: 'POST' });
const { streamToken } = await res.json();

// 2. Connect
const es = new EventSource(
  `https://api.fundedfast.eu/v1/events?token=${streamToken}&userId=player-42`
);

es.addEventListener('challenge.completed', (e) => {
  const data = JSON.parse(e.data);
  showNotification('Challenge completed!');
});

es.addEventListener('cooldown.triggered', (e) => {
  const { expiresAt } = JSON.parse(e.data); // when the pause ends
  disableBettingUntil(expiresAt);
});

Your backend (token proxy) ​

javascript
// Express route that your frontend calls
app.post('/api/fast/user-token', async (req, res) => {
  const userId = req.session.userId; // from your auth
  const response = await fetch('https://api.fundedfast.eu/v1/sse/token', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': process.env.FAST_SERVER_KEY, // key-..., never shipped to the browser
    },
    body: JSON.stringify({ userId }),
  });
  const data = await response.json();
  res.json(data);
});

With the FAST Widget ​

The widget handles SSE automatically. Give it a user token your backend minted with the server key; it renews the token itself after that:

html
<!-- Optional, recommended: opens the API connection while the script loads. -->
<link rel="preconnect" href="https://api.fundedfast.eu" crossorigin>
<script
  src="https://cdn.fundedfast.eu/fast-widget.iife.js"
  data-fast-widget
  data-api-key="pk_your-widget-key"
  data-user-id="player-42"
  data-user-token="TOKEN_FROM_YOUR_BACKEND"
  data-api-base="https://api.fundedfast.eu/v1"
></script>

Without data-user-token the widget can mint a token with the public key only on a staging tenant.

You can also mount it from script instead of data attributes (window.FastWidget.mount() returns an instance with update/destroy/open):

javascript
const widget = FastWidget.mount({
  apiKey: 'pk_your-widget-key',
  userId: 'player-42',
  apiBase: 'https://api.fundedfast.eu/v1',
  userToken: tokenFromYourBackend, // pre-generated; data-user-token in HTML form
});

// Later, when your backend hands you a refreshed token (e.g. onTokenExpired):
widget.update({ userToken: refreshedToken });

Keep-alive ​

The server sends a comment line (: keepalive) every 30 seconds to prevent connection timeouts.

Error handling ​

If the connection drops, EventSource auto-reconnects. On token expiry (401 response), fetch a new token and create a new EventSource instance.

A client that falls more than about 1 MB behind in reading is disconnected; it reconnects and refetches on connected. When the tenant has reached its stream limit (500 open streams per API instance), the server sends an error event with {"error":"too_many_connections"} and closes the stream.

BLACKLINE CONSULTING d.o.o.