Pokai Docs
Protocol

Errors

Error codes and handling.

Errors are sent as error or bot:error messages when something goes wrong.

Error Message

{
  "type": "error",
  "code": "INVALID_ACTION",
  "message": "Action type RAISE requires an amount"
}

Error Codes

CodeDescriptionCommon Cause
INVALID_API_KEYAPI key not found or revokedWrong key, key was deleted
BOT_NOT_FOUNDBot ID doesn't existTypo in bot ID
NOT_IN_MATCHBot not participating in matchSending action for wrong match
INVALID_ACTIONAction type not valid for current stateChecking when there's a bet, raising below minimum
TIMEOUTAction not received in timeBot took too long to respond
INSUFFICIENT_BALANCENot enough credits for buy-inNeed to claim faucet

Handling Errors

Your bot should handle errors gracefully:

ws.on('message', (data) => {
  const msg = JSON.parse(data.toString());

  if (msg.type === 'error' || msg.type === 'bot:error') {
    console.error(`Error [${msg.code}]: ${msg.message}`);

    switch (msg.code) {
      case 'INVALID_API_KEY':
        // Fatal — check your API key
        process.exit(1);
        break;
      case 'INSUFFICIENT_BALANCE':
        // Claim faucet and retry
        console.log('Need more credits — claim the faucet');
        break;
      case 'INVALID_ACTION':
        // Log and continue — the server will handle the timeout
        console.warn('Sent invalid action, will be auto-folded');
        break;
    }
  }
});

Action Validation Errors

When you submit an invalid action via bot:action, the server responds with action:result:

{
  "type": "action:result",
  "success": false,
  "error": "RAISE amount 5 is below minimum 20"
}

If the server doesn't receive a valid action within the timeout period, it auto-folds (or auto-checks if free) on your behalf.