Bet Endpoint
This document describes the Bet endpoint for Klas Gaming Casino integration. This endpoint is used to withdraw funds from the player account. The operation is idempotent: if the wallet receives more than one request with the same transfer_id, the transaction must be registered only once.
Endpoint
POST {WEBHOOK_URL}/bet
Note:
{WEBHOOK_URL}is the webhook URL provided by the operator. Klas Gaming will send POST requests to this endpoint.
Headers
X-Signature: HMAC-SHA256 signature for message integrity (see Security Headers)Content-Type: application/json
Request Body
{
"request_id": "string",
// Required. Unique request identifier.
"timestamp": 1234567890,
// Required. Timestamp of the request (number).
"session_id": "string"",
// Required. Unique session identifier.
"player_id": "string",
// Required. Unique player identifier from operator system.
"game_code": "string",
// Required. Game key of the active player's game.
"transfer_id": "string",
// Required. Unique reference of the transaction.
"round_id": "string",
// Required. Unique reference of the game round.
"round_completed": true,
// Required. Specify if this is the last transaction for the current round (boolean).
"amount": "100",
// Required. Transfer amount.
"currency": "EUR",
// Required. Currency code (ISO-4217, e.g., EUR, USD).
"reason": "BET",
// Required. Transfer reason.
"gift_spin": {
// Optional. Object with bonus/campaign info.
// ...
}
}
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| request_id | string | Yes | Unique request identifier. |
| timestamp | number | Yes | Timestamp of the request. |
| session_id | string | Yes | Unique identifier of the current player session. |
| player_id | string | Yes | Unique identifier of the player from the operator's system. |
| game_code | string | Yes | Game key of the active player's game. |
| transfer_id | string | Yes | Unique reference of the transaction. |
| round_id | string | Yes | Unique reference of the game round. |
| round_completed | boolean | Yes | Specify if this is the last transaction for the current round. |
| amount | string | Yes | Transfer amount. |
| currency | string | Yes | Currency code (ISO-4217, e.g., EUR, USD). |
| reason | string | Yes | Transfer reason. |
| gift_spin | object | No | Object with bonus/campaign info (bonus code, campaign id, spins, etc.). |
Response Body
{
"balance": "30",
// Player balance (e.g., 30 EUR)
"casino_transfer_id": "string",
// Unique reference of the transfer created in the operator's system
"bonus_amount": "0",
// Amount withdrawn from player's bonus money account
"real_amount": "100",
// Amount withdrawn from player's real money account
"status_code": "OK"
// Status code of the execution
}
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| balance | string | Yes | Player balance (EUR 30). |
| casino_transfer_id | string | Yes | Unique reference of the transfer created in the operator's system. |
| bonus_amount | string | Yes | Amount withdrawn from the player's bonus money account. Return 0 if the operator's backend does not support bonus money. Example: If a player bets 100 units and 30 units are from bonus money, then bonus_amount = 30. |
| real_amount | string | Yes | Amount withdrawn from the player's real money account. If the operator's backend does not support bonus money, then the value of this field should be equal to the amount of the transaction request. Example: If a player bets 100 units and 70 units are from real money, then real_amount = 70. |
| status_code | string | Yes | Status code of the execution. |
Note:
- If your backend does not support bonus money, always set
bonus_amountto 0 andreal_amountto the full transaction amount.- These fields help distinguish between real and bonus funds used in a transaction.
Possible Status Codes
| Status Code | Reason |
|---|---|
| OK | Request successful |
| ERR_INTEGRITY_CHECK_FAILED | Message integrity check failed |
| ERR_NOT_ENOUGH_MONEY | Player account does not have sufficient funds |
| ERR_LIMIT_REACHED | Player has exceeded his game limits (responsible gaming) |
| ERR_UNKNOWN | Internal server error |
| ERR_TIMEOUT | Timeout exception |
Flow Description
- Klas Gaming sends a POST request to
/betwith the required fields and headers. - The backend processes the request, withdraws the funds, and returns the updated balance and transaction details.
- The response includes the player's balance, transaction references, and a status code indicating the result.
Example Request
curl -X POST https://<your-api>/bet \
-H "Content-Type: application/json" \
-H "X-Signature: <hmac_signature>" \
-d '{
"request_id": "1234-5678-90ab-cdef12345678",
"timestamp": 1710000000,
"session_id": "1234-5678-90ab-cdef12345678",
"player_id": "12001",
"game_code": "ABSlot",
"transfer_id": "1234-5678-90ab-cdef12345678",
"round_id": "1234-5678-90ab-cdef12345678",
"round_completed": true,
"amount": "100",
"currency": "EUR",
"reason": "BET",
"gift_spin": {}
}'
Example Response
{
"balance": "30",
"casino_transfer_id": "operator_tx_1234-5678-90ab-cdef12345678",
"bonus_amount": "0",
"real_amount": "100",
"status_code": "OK"
}
Notes
-- The operation is idempotent: if the same transfer_id is used more than once, the transaction is only registered once.
- All requests must be signed using the HMAC mechanism described in Security Headers.
- For more details, refer to the Klas Gaming integration documentation or contact your integration representative.