REST & AsyncAPI reference
Complete REST API, seamless wallet callback, and WebSocket protocol reference compiled from the OpenAPI 3.1 and AsyncAPI 3.1 specifications.
- OpenAPI version:
3.1.0(BetPlug APIv0.1.0) - AsyncAPI version:
3.1.0(BetPlug live games and webhooksv0.1.0) - REST base URL:
https://api.(example hostname)betrail. example - Live WebSocket host:
wss://live.betrail. example/ v1/ live/ {game}
Shared HTTP errors & retry matrix#
Every REST error returns RFC 9457 application/ (Problem) with a unique Betrail-Request-Id header (type, title, status, detail, instance, code (ProblemCode), plus max_stake on 422 max_stake and elapsed_seconds/net_result on 409 reality_check_due).
{
"type": "https://betrail.example/problems/max_stake",
"title": "Stake exceeds maximum allowed for this target",
"status": 422,
"detail": "Stake exceeds the brand max_profit cap.",
"instance": "/v1/rounds",
"code": "max_stake",
"max_stake": "5.00000000"
}| HTTP | ProblemCode values | Retryability |
|---|---|---|
400 | invalid_request | No — fix malformed JSON, headers, or schema |
401 | unauthorized, session_expired | Re-sign with fresh timestamp & nonce (or re-launch if session_expired) |
402 | credits_exhausted, plan_inactive | After topping up live USD credits or reactivating plan |
403 | forbidden, origin_not_allowed, player_blocked, jurisdiction_ | No — fix key scope, allowed origin, player status, or jurisdiction policy |
404 | unknown_game, unknown_version, not_found | No — verify resource ID and canonical GameSlug |
409 | not_offered, odds_changed, closed, limit, pending, seed_not_revealed, idempotency_key_in_use, insufficient_funds, limit_exceeded, max_exposure, round_open, reality_check_due | idempotency_key_in_use/pending only: retry same Idempotency-Key + fresh nonce; resolve state for others |
413 | body_too_large | No — keep request body <= 64 KB |
415 | unsupported_encoding | No — send uncompressed identity JSON |
422 | invalid_input, invalid_action, stake_out_of_range, max_stake, unknown_profile, idempotency_key_reused | No — fix parameters or mint a new Idempotency-Key |
429 | rate_limited | Yes — wait Retry-After seconds, reuse Idempotency-Key, fresh nonce |
500 | no_acceptable_draw, internal | Yes — retry same Idempotency-Key + body with fresh timestamp & nonce |
503 | wallet_unavailable | Only when Retry-After is present (bulkhead); without it the round voided |
For the complete per-game parameter, action, and RNG matrix across every mounted catalog game, see Game catalog & live protocol or the single-file /llms-full.txt bundle.
Public & operator REST operations#
Select any operation to inspect authentication, parameters, contract notes, responses, and JSON examples.
GET/healthzLiveness probe
GET/v1/roundsList rounds
POST/v1/roundsOpen a round
GET/v1/rounds/{id}Read a round
POST/v1/rounds/{id}/actions Play one step of an open round
GET/v1/rounds/{id}/verify Verify a round
GET/v1/players/{player_ref}/seeds/{game} Read a player's seeds
POST/v1/players/{player_ref}/seeds/{game}/rotate Rotate a player's seeds
PUT/v1/players/{player_ref}/status Set a player's status
POST/v1/players/{player_ref}/force-close Force-close a player's open rounds
POST/v1/launchLaunch a game for a player
POST/v1/sessionsExchange a launch token for a session token
POST/v1/demo/sessionsStart a demo session
GET/v1/session/rounds List the session player's rounds
POST/v1/session/rounds Open a round in the session
GET/v1/session/rounds/{id} Read a round of the session's player
POST/v1/session/rounds/{id}/actions Play one step of a round in the session
GET/v1/session/balance Read the session player's balance
GET/v1/session/seedsRead the session player's seeds
PUT/v1/session/client-seed Set the session player's next client seed
POST/v1/session/seeds/rotate Rotate the session player's seeds
POST/v1/sessions/current/reality-check Acknowledge a due reality check on the current player session
POST/v1/live/{game}/tickets Get a join ticket for a live game's socket
POST/v1/live/{game}/bets Place a bet on a live show
POST/v1/live/meme-trade/buy-ins Buy into the open MEME_TRADE round balance
POST/v1/topup-events/{provider} Top-up provider: report a checkout's event
Seamless wallet callbacks#
BetPlug calls these four endpoints on your brand's wallet base URL (POST {wallet_base}/, /debit, /credit, /rollback). Every verified call on a live brand must return Betrail-Timestamp and Betrail-Signature (betrail-v1-answer, ed25519= or v1=), including 4xx WalletRefusal / WalletProtocolRefusal responses.
Select any operation to inspect authentication, parameters, contract notes, responses, and JSON examples.
POST{wallet_base}/balance Wallet: read a player's balance
POST{wallet_base}/debit Wallet: take a stake
POST{wallet_base}/credit Wallet: pay a round
POST{wallet_base}/rollback Wallet: undo a debit
AsyncAPI channels, operations, and messages#
Select any operation to inspect authentication, parameters, contract notes, responses, and JSON examples.
SEND/v1/live/{game}The show's frames to the player's socket (snapshot, round, step, result, paid, error).
RECEIVE/v1/live/{game}A player's command (a fresh snapshot, or an in-round command), answered by an ack frame with the same request id.
SEND{operator_webhook_url}One event, POSTed to the operator's endpoint (round.settled, credits.low, credits.exhausted).
AsyncAPI message payloads#
LiveFrame(Live frame, schemaLiveFrame): A frame from the show to a player.LiveSettled(Live bet settled, schemaLiveSettledFrame): The frame that tells a player their bet settled, by play, a force-close or an outage.StackOPassFrame(STACKOPASS live frame, schemaStackOPassFrame): A frame from a STACKOPASS table to a player, its hand's settlement included.StackOPassCommand(STACKOPASS live command, schemaStackOPassCommand): A STACKOPASS player's socket command (snapshot, watch, open, pass, cashout, leave).MemeTradeFrame(MEME_TRADE live frame, schemaMemeTradeFrame): A frame from the MEME_TRADE v2 show to a player, including skipped_link.LiveCommand(Live command, schemaLiveCommand): A command from a player to the show.KombatmpFrame(KOMBATMP live frame, schemaKombatmpFrame): A frame from a KOMBATMP round to a player, its settlement included.KombatmpCommand(KOMBATMP live command, schemaKombatmpCommand): A KOMBATMP player's socket command (snapshot only; bets go in over REST).TrapdoorFrame(TRAPDOOR live frame, schemaTrapdoorFrame): A frame from a TRAPDOOR show to a player, its settlement included.TrapdoorCommand(TRAPDOOR live command, schemaTrapdoorCommand): A TRAPDOOR player's socket command (snapshot, pick, bank, plan).CrashFrame(CRASH live frame, schemaCrashFrame): A frame from a CRASH show to a player, its settlement included.CrashCommand(CRASH live command, schemaCrashCommand): A CRASH player's socket command (snapshot, cashout).WebhookEvent(Webhook event, schemaWebhookEvent): One event delivered to an operator.RoundSettled(round.settled, schemaRoundSettledEvent): A round settled, in either integration mode (live games included; a MEME_TRADE player-round).CreditsLow(credits.low, schemaCreditsLowEvent): The operator's credits fell below its threshold.CreditsExhausted(credits.exhausted, schemaCreditsExhaustedEvent): The operator's credits reached 0 or less, so new live rounds are refused.
OpenAPI component schemas#
All object schemas enforce strict JSON decoding (additionalProperties: false) unless noted otherwise.
Key schemas are listed below; filter or expand the full contract, or download OpenAPI 3.1, AsyncAPI 3.1, or api-reference.md.
Amount
Multiplier
CurrencyCode
GameSlug
ClientSeed
DiceParams
PacksView
RoundCreate
RoundAction
Round
Verification
LaunchCreate
Launch
SessionCreate
Session
LiveTicket
LiveBetCreate
WalletBalanceRequest
WalletDebitRequest
WalletCreditRequest
WalletRollbackRequest
WalletAnswer
WalletRefusal
ProblemCode
Problem
AsyncAPI component schemas#
All object schemas enforce strict JSON decoding (additionalProperties: false) unless noted otherwise.
Key schemas are listed below; filter or expand the full contract, or download OpenAPI 3.1, AsyncAPI 3.1, or api-reference.md.