Skip to main content

Microbets aggregation (casino spins)

Slot games (and similar casino mechanics) can generate a lot of events: a single session can produce hundreds or thousands of spins.

If you call betPlaced for every spin, you may end up with:

  • Too many network calls
  • Excessive write volume
  • Harder mission “qualifier matching” when you actually want to count aggregated play

Microbets solve this by letting you submit many spins quickly, and letting SavageTech aggregate them into fewer “batched” events when thresholds are met.

When to use microbets

Use microbets when:

  • You have high-frequency spin/round events (slots, crash games, fast roulette simulations, etc.)
  • You want missions like “Spin 50 times” or “Wager $10 total” to progress efficiently
  • You want batching based on time window or total wager threshold

How aggregation works (conceptually)

Step 1 — Get a short-lived microbet token

This token ties a submit session to a gameId and expires quickly.

  • Method: POST
  • Path: /api/v1/activity/microBetPlaced

Body

{
"gameId": "slots"
}

Response

{
"token": "0f7b0d4e-....",
"expiresAt": 1730000000000
}

Step 2 — Submit spins (micro-bets)

You submit one or many spins at a time. The API will:

  1. Validate the microbet token (Authorization Bearer)
  2. Validate your vendor credentials (x-client-id / x-client-secret)
  3. Add each spin to the player’s aggregation bucket
  4. Flush (publish an aggregated bet) when thresholds are met
  • Method: POST
  • Path: /api/v1/activity/microBetPlaced/submit
  • Headers:
    • x-client-id
    • x-client-secret
    • authorization: Bearer <microbetToken>

Body

{
"playerId": "player-123",
"bets": [
{
"spinId": "spin-001",
"amount": 0.2,
"currency": "usd",
"originalAmount": 0.2,
"originalCurrency": "usd",
"payout": 0,
"outcome": "loss",
"additionalData": { "machine": "golden-dragon" },
"activityRequestId": "evt_spin_spin-001"
}
]
}

cURL example (submit multiple spins)

# 1) Get token (copy `token` from the JSON response)
curl -X POST "$SAVAGE_API_BASE_URL/api/v1/activity/microBetPlaced" \
-H "content-type: application/json" \
-d '{ "gameId": "slots" }'

# 2) Paste it here
TOKEN="PASTE_TOKEN_HERE"

# 3) Submit spins (batched)
curl -X POST "$SAVAGE_API_BASE_URL/api/v1/activity/microBetPlaced/submit" \
-H "content-type: application/json" \
-H "x-client-id: $SAVAGE_X_CLIENT_ID" \
-H "x-client-secret: $SAVAGE_X_CLIENT_SECRET" \
-H "authorization: Bearer $TOKEN" \
-d '{
"playerId": "player-123",
"bets": [
{ "spinId": "spin-001", "amount": 0.2, "currency": "usd", "originalAmount": 0.2, "originalCurrency": "usd", "payout": 0, "outcome": "loss" },
{ "spinId": "spin-002", "amount": 0.2, "currency": "usd", "originalAmount": 0.2, "originalCurrency": "usd", "payout": 0, "outcome": "loss" },
{ "spinId": "spin-003", "amount": 0.2, "currency": "usd", "originalAmount": 0.2, "originalCurrency": "usd", "payout": 1.0, "outcome": "win" }
]
}'

When does the API “flush” an aggregation?

Aggregation flush happens when either of these vendor-configured thresholds is met:

  • Time window: reconciliationTime milliseconds since the first spin in the bucket
  • Total wager threshold: minimumMicrobetThreshold (converted to base currency using vendor currency rates)

When a flush happens, the API publishes a single aggregated bet downstream and clears the bucket for that player.

Best practices

  • Batch spins: submit 10–100 spins per call (whatever matches your traffic/latency goals).
  • Set spinId and activityRequestId: use stable ids from your game server so you can trace issues.
  • Keep additionalData minimal: only fields you actually need for mission qualifiers or analytics.