Overview
Backend integration with Phoenix Games
Backend Integration
Your backend does two things:
- Receives webhook calls from Phoenix during gameplay (withdraw, deposit, rollback, balance check)
- Calls the Operator API to create game sessions, look up bets, and grant free bets
What You Implement
Four webhook endpoints at your api_url:
| Endpoint | When it's called | What you do |
|---|---|---|
POST /withdraw | Player places a bet | Deduct the wager from their balance |
POST /deposit | Bet settles (win or loss) | Credit the winnings (0 for a loss) |
POST /rollback | Bet cancelled before it starts | Reverse the withdraw |
POST /player-balance | Balance check | Return current balance |
Plus JWT token generation for starting game sessions.
What You Call
Three endpoints on Phoenix's Operator API (operators.phoenixbet.io):
| Endpoint | Purpose |
|---|---|
GET /api/v0.2/fetch-games | List your configured games and instances |
GET /api/v0.2/fetch-bet/{bet_id} | Look up a specific bet's status |
POST /api/v0.2/free-bet/grant | Grant free bets to players |
Response Format
All webhook endpoints return the same JSON structure:
{"type": "SUCCESS", "balance": 1234.56, "timestamp": 1712401234567}| Field | Type | Description |
|---|---|---|
type | string | "SUCCESS" or "ERROR" |
balance | float | Player's current balance (required for SUCCESS, optional for ERROR) |
timestamp | integer | Unix milliseconds (required for SUCCESS) |
code | string | Error code (required for ERROR) |
Always return HTTP 200 - both for success and error. The outcome is in the type field.