Phoenix Games
Webhook Endpoints

Withdraw

Deduct player balance for bets and rain events

POST {api_base_url}/withdraw

Triggered when a player initiates an action that deducts their balance (e.g., placing a bet or triggering a "rain" event in chat).

Request Fields

FieldTypeDescription
player_idstringUnique identifier for the player
amountintegerAmount to withdraw in cents (e.g., 5000 = $50.00)
gamestringGame ID (e.g., "aviator")
instance_idstringID of the specific game instance
actionenumBET (placing a bet) or RAIN (initiating rain drop)
action_idstringID to uniquely track this action
tx_idstringUnique transaction ID

Important Notes

  • The operator must ensure that the player has sufficient balance to cover the amount before proceeding
  • amount is always expressed in cents (i.e., the true value multiplied by 100)
  • Be sure to factor this into all calculations and comparisons to avoid incorrect deductions
  • Handle concurrent requests properly - Use database transactions or locking mechanisms to prevent race conditions when multiple withdraw requests arrive simultaneously for the same player
  • Check for idempotency by tx_id - Always verify if the transaction has already been processed to avoid double spending

Response Format

All webhook endpoints must return a response with a type field indicating success or error.

Success Response

{
  "type": "SUCCESS",
  "balance": 1234.56,
  "timestamp": 1712401234567
}
FieldTypeDescription
typestringAlways "SUCCESS" for successful operations
balancefloatUpdated player balance after withdrawal
timestampintegerTimestamp in milliseconds

Error Response

{
  "type": "ERROR",
  "balance": 1234.56,
  "code": "INSUFFICIENT_BALANCE"
}
FieldTypeDescription
typestringAlways "ERROR" for failed operations
balancefloat (optional)Current player balance (if available)
codestringError code explaining failure reason

Common Error Codes

  • INSUFFICIENT_BALANCE - Player doesn't have enough funds
  • INVALID_REQUEST - Request format or data is invalid