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
| Field | Type | Description |
|---|---|---|
player_id | string | Unique identifier for the player |
amount | integer | Amount to withdraw in cents (e.g., 5000 = $50.00) |
game | string | Game ID (e.g., "aviator") |
instance_id | string | ID of the specific game instance |
action | enum | BET (placing a bet) or RAIN (initiating rain drop) |
action_id | string | ID to uniquely track this action |
tx_id | string | Unique transaction ID |
Important Notes
- The operator must ensure that the player has sufficient balance to cover the
amountbefore proceeding amountis 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
}| Field | Type | Description |
|---|---|---|
type | string | Always "SUCCESS" for successful operations |
balance | float | Updated player balance after withdrawal |
timestamp | integer | Timestamp in milliseconds |
Error Response
{
"type": "ERROR",
"balance": 1234.56,
"code": "INSUFFICIENT_BALANCE"
}| Field | Type | Description |
|---|---|---|
type | string | Always "ERROR" for failed operations |
balance | float (optional) | Current player balance (if available) |
code | string | Error code explaining failure reason |
Common Error Codes
INSUFFICIENT_BALANCE- Player doesn't have enough fundsINVALID_REQUEST- Request format or data is invalid