Skip to content

Error Handling

All error responses use the Twirp format with an api_code in the meta field:

{
"code": "invalid_argument",
"msg": "Player has not enough funds to process an action.",
"meta": {
"api_code": "100",
"api_message": "Player has not enough funds to process an action.",
"balance": "50.00"
}
}
FieldTypeRequiredDescription
codestringYesTwirp error code (see below)
msgstringYesHuman-readable error description
meta.api_codestringYesNumeric API error code
meta.api_messagestringYesAPI error message
meta.balancestringConditionalCurrent balance — required when api_code is 100, 105, or 106

Only two Twirp codes are used:

Twirp CodeHTTP StatusMeaning
invalid_argument400Client error (bad request, auth failure, business rule violation)
internal500Server error

Section titled “Funds-Related Codes (balance required in response)”
api_codeDescriptionOperator Action
100Insufficient fundsReturn current balance in meta. Beexar shows “not enough funds” to player.
105Bet limit exceededReturn current balance in meta.
106Win limit exceededReturn current balance in meta.
api_codeDescriptionOperator Action
101Player not found or disabledBeexar terminates the session.
api_codeDescriptionOperator Action
400Bad requestMalformed JSON, missing required fields.
403Invalid signatureHMAC-SHA256 signature mismatch. Verify AUTH_TOKEN.
155Transaction tombstonedThe id_provider was already rolled back. Reject the action.
api_codeDescriptionOperator Action
500Internal server errorGeneric server failure. Beexar will retry.

When Beexar receives an error or timeout from the operator’s wallet:

ResponseBeexar Behavior
HTTP 200Success, no retry
HTTP 400, api_code 100Insufficient funds — no retry, show error to player
HTTP 400, api_code 403Signature error — no retry (configuration issue)
HTTP 400, api_code 155Tombstoned — no retry, action already cancelled
HTTP 400, otherBad request — no retry (logged)
HTTP 500Server error — retry with exponential backoff
TimeoutNo response — retry with exponential backoff
ParameterBetWinRollbackFinish
Max attempts4 (1 + 3 retries)UnlimitedUnlimited
Initial backoff100 ms10 s10 s
Max backoff400 ms1 hour1 hour
Backoff multiplier2x2x2x
Total time budget5 sUp to 7 daysUp to 7 days
ActionBehavior on failure
BetWinError returned to player. The round is considered “not started” — no rollback is sent.
RollbackRetried via the outbox worker (async, up to 7 days). Rollbacks are critical for financial consistency.
FinishRetried via the outbox worker (async, up to 7 days). Finish is informational — financial actions already completed.

  1. Process quickly — aim for response times under 500ms
  2. Return early — validate and respond before heavy background processing
  3. Handle retries gracefully — same id_provider = return original response (idempotency)
  4. Never block on external calls — if your wallet depends on downstream services, implement circuit breakers
sequenceDiagram
    participant Beexar
    participant Wallet as Operator Wallet

    Beexar->>Wallet: POST /betwin (id_provider: "tx_1")
    Note right of Wallet: Server slow / timeout
    Beexar->>Wallet: POST /betwin (retry 1, same id_provider)
    Note right of Wallet: Still no response
    Beexar->>Wallet: POST /betwin (retry 2, same id_provider)
    Note right of Wallet: Still no response
    Beexar->>Wallet: POST /betwin (retry 3, same id_provider)
    Note right of Wallet: Still no response
    Note over Beexar: All retries exhausted — error shown to player

  1. Always return valid JSON — even on errors, return the Twirp error format
  2. Include balance on funds-related codes — api_codes 100, 105, 106
  3. Log all requests — include id_provider, round_id, and account_id for debugging
  4. Monitor response times — alert if P99 exceeds 1 second
  5. Implement health checks — Beexar may check endpoint availability