Skip to content
BetPlugDocs
DocsAPI & tools
View .md twin

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 API v0.1.0)
  • AsyncAPI version: 3.1.0 (BetPlug live games and webhooks v0.1.0)
  • REST base URL: https://api.betrail.example (example hostname)
  • Live WebSocket host: wss://live.betrail.example/v1/live/{game}

Shared HTTP errors & retry matrix#

Every REST error returns RFC 9457 application/problem+json (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).

JSON
{
  "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"
}
HTTPProblemCode valuesRetryability
400invalid_requestNo — fix malformed JSON, headers, or schema
401unauthorized, session_expiredRe-sign with fresh timestamp & nonce (or re-launch if session_expired)
402credits_exhausted, plan_inactiveAfter topping up live USD credits or reactivating plan
403forbidden, origin_not_allowed, player_blocked, jurisdiction_not_allowedNo — fix key scope, allowed origin, player status, or jurisdiction policy
404unknown_game, unknown_version, not_foundNo — verify resource ID and canonical GameSlug
409not_offered, odds_changed, closed, limit, pending, seed_not_revealed, idempotency_key_in_use, insufficient_funds, limit_exceeded, max_exposure, round_open, reality_check_dueidempotency_key_in_use/pending only: retry same Idempotency-Key + fresh nonce; resolve state for others
413body_too_largeNo — keep request body <= 64 KB
415unsupported_encodingNo — send uncompressed identity JSON
422invalid_input, invalid_action, stake_out_of_range, max_stake, unknown_profile, idempotency_key_reusedNo — fix parameters or mint a new Idempotency-Key
429rate_limitedYes — wait Retry-After seconds, reuse Idempotency-Key, fresh nonce
500no_acceptable_draw, internalYes — retry same Idempotency-Key + body with fresh timestamp & nonce
503wallet_unavailableOnly 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}/actionsPlay one step of an open round
GET/v1/rounds/{id}/verifyVerify a round
GET/v1/players/{player_ref}/seeds/{game}Read a player's seeds
POST/v1/players/{player_ref}/seeds/{game}/rotateRotate a player's seeds
PUT/v1/players/{player_ref}/statusSet a player's status
POST/v1/players/{player_ref}/force-closeForce-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/roundsList the session player's rounds
POST/v1/session/roundsOpen a round in the session
GET/v1/session/rounds/{id}Read a round of the session's player
POST/v1/session/rounds/{id}/actionsPlay one step of a round in the session
GET/v1/session/balanceRead the session player's balance
GET/v1/session/seedsRead the session player's seeds
PUT/v1/session/client-seedSet the session player's next client seed
POST/v1/session/seeds/rotateRotate the session player's seeds
POST/v1/sessions/current/reality-checkAcknowledge a due reality check on the current player session
POST/v1/live/{game}/ticketsGet a join ticket for a live game's socket
POST/v1/live/{game}/betsPlace a bet on a live show
POST/v1/live/meme-trade/buy-insBuy 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}/balance, /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}/balanceWallet: read a player's balance
POST{wallet_base}/debitWallet: take a stake
POST{wallet_base}/creditWallet: pay a round
POST{wallet_base}/rollbackWallet: 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, schema LiveFrame): A frame from the show to a player.
  • LiveSettled (Live bet settled, schema LiveSettledFrame): The frame that tells a player their bet settled, by play, a force-close or an outage.
  • StackOPassFrame (STACKOPASS live frame, schema StackOPassFrame): A frame from a STACKOPASS table to a player, its hand's settlement included.
  • StackOPassCommand (STACKOPASS live command, schema StackOPassCommand): A STACKOPASS player's socket command (snapshot, watch, open, pass, cashout, leave).
  • MemeTradeFrame (MEME_TRADE live frame, schema MemeTradeFrame): A frame from the MEME_TRADE v2 show to a player, including skipped_link.
  • LiveCommand (Live command, schema LiveCommand): A command from a player to the show.
  • KombatmpFrame (KOMBATMP live frame, schema KombatmpFrame): A frame from a KOMBATMP round to a player, its settlement included.
  • KombatmpCommand (KOMBATMP live command, schema KombatmpCommand): A KOMBATMP player's socket command (snapshot only; bets go in over REST).
  • TrapdoorFrame (TRAPDOOR live frame, schema TrapdoorFrame): A frame from a TRAPDOOR show to a player, its settlement included.
  • TrapdoorCommand (TRAPDOOR live command, schema TrapdoorCommand): A TRAPDOOR player's socket command (snapshot, pick, bank, plan).
  • CrashFrame (CRASH live frame, schema CrashFrame): A frame from a CRASH show to a player, its settlement included.
  • CrashCommand (CRASH live command, schema CrashCommand): A CRASH player's socket command (snapshot, cashout).
  • WebhookEvent (Webhook event, schema WebhookEvent): One event delivered to an operator.
  • RoundSettled (round.settled, schema RoundSettledEvent): A round settled, in either integration mode (live games included; a MEME_TRADE player-round).
  • CreditsLow (credits.low, schema CreditsLowEvent): The operator's credits fell below its threshold.
  • CreditsExhausted (credits.exhausted, schema CreditsExhaustedEvent): 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.

Amount
RoundSettledEvent
CreditsLowEvent
CreditsExhaustedEvent
LiveFrame
LiveSettledFrame
WebhookEvent
MemeTradeFrame
KombatmpFrame
StackOPassFrame
TrapdoorFrame
CrashFrame
Enter to openEsc to close