1. Tickets
[Game] FairPlay API
  • Getting Started
    • Introduction
    • Session and Token
    • Request and Response
    • Real-time Events (SSE)
    • Lotto Rules — หวยเฮงเฮง
    • Provably Fair
  • Player
    • Demo
      • Demo Login
    • Player Bet History
      GET
  • Common
    • Game
      • By Game Code
        • Provably Fair
          • Set Client Seed
          • Verify Result
          • Get Revealed Server Seed
        • Check Session
        • Get Balance
        • Get Provably-Fair State
      • Lobby Game List
  • Wallet
    • Wallet Status
      GET
  • Game
    • Lotto (หวยเฮงเฮง)
      • Lotto Rules
      • Rooms
        • By Room
          • Join Round
          • Place Multi-player Bet
          • Get Round Result
          • Room Event Stream
      • Tickets
        • Create Ticket
          POST
        • Inquiry My Tickets
          POST
        • Get Ticket
          POST
      • Round
        • Get My Bets
        • Get My Result
        • Get Round Provably Fair
      • Results
        • Inquiry Results
      • Get Rooms
        GET
      • Get Current Round
        POST
      • Get Pay Table
        GET
  • Appendix
    • Game List
    • Error Codes
    • Rate Limits
  • Language List
    GET
  • Ping
    GET
  • Schemas
    • DemoLoginRequest
    • DemoLoginResponse
    • DemoProfileResponse
    • ProfileResponse
    • GetHistoryResponse
    • BetRecord
    • GameInfo
    • Room
    • GetGameResponse
    • BetRequest
    • Bet
    • BetResponse
    • BetResult
    • GetProvablyFairResponse
    • SetClientSeedRequest
    • SetClientSeedResponse
    • RotateServerSeedResponse
    • VerifyResultRequest
    • VerifyResultResponse
    • GetServerSeedResponse
    • GetStatusResponse
    • JoinRoundResponse
    • PlaceMultiPlayerBetRequest
    • PlaceBetResponse
    • RoundResultResponse
    • SuccessResponse
    • ErrorResponse
  1. Tickets

Create Ticket

POST
/gapi/v1/g/lotto/tickets/create
Confirms the whole basket as one ticket with one debit, and returns the ticket id, the new balance and each line's settle rate and potential win. Idempotent per requestId.
Auth: Player session — Authorization: Bearer {token}
Rate limit: 60 requests per 60 s per IP (LOTTO_CREATE_TICKET)
Games: LOTTO
Rules
Lotto only: the route is under /g/lotto, so system maintenance and Lotto's own maintenance window both answer 503 99915.
Body keys are requestId, roomId, roundId (lower-case d); the returned ticket id is betID (capital ID).
requestId is a client-generated idempotency key, unique per player (not per round). After a timeout or a dropped connection, resend the SAME requestId to get the same ticket back with no second debit. Use a new one for every new ticket: an old one returns the old ticket (200) and places nothing, even in a later round or with a different body.
A replay does not re-check the body. The replayed balance is the balance at the original debit, and rate / isLucky / potentialWin are recomputed from the current lucky number, so after the round settles they can differ from the first response.
409 99964 means another request with the same requestId is in progress; retry with the same requestId to receive that ticket.
1-20 items; no two items with the same betType + number (exact strings: 3-TOAD "917" and "179" are different; 3-BOTTOM "917" plus 3-TOAD "917" is allowed).
All-or-nothing: items are checked in order (the first failure is reported) before any debit, then the total is debited once.
Each item needs amount > 0 and ≥ the room minimum (limits.minPerItem). The round-wide total on one bet type + number across all players must stay ≤ limits.maxPerNumber (equal is allowed).
Amounts are JSON numbers (a numeric string is also accepted), decimals allowed. In the response totalAmount, amount and potentialWin are JSON numbers but balance is a decimal string.
potentialWin = amount × rate truncated to 2 decimals (gross, stake included). isLucky is true only for 2-BOTTOM lines on the current lucky number, and their rate includes the lucky multiplier.
If the round closes while the ticket is being placed, the debit is refunded and the call answers 400 99942.
createdAt: a fresh create returns the server's local time offset with nanoseconds; a replay returns UTC with milliseconds. Parse it as a date.
Validation failures answer 400 99911 with a description listing the fields, e.g. requestId is required; betType is required.
Flow
1.
Validate the body; reject more than 20 items or a duplicate bet type + number.
2.
If this player already has a ticket with this requestId, return it (no new debit).
3.
Check the round (exists, this room, session currency, still betting), the game's availability and the room.
4.
Check every item in order: amount > 0, bet type and number format, a positive rate in the round's payout table, room minimum, then the round-wide per-number cap.
5.
Debit the ticket total once from the player's wallet.
6.
MULTI_CSEED rounds: claim the first free client-seed slot and broadcast SSE seed_slot_updated; a failed claim never fails the ticket.
7.
Store the ticket (status WAITING) and re-check the round; if it closed meanwhile, refund and reject.
8.
Return the ticket with per-line rates and potential wins.

Request

Query Params

Header Params

Body Params application/json

Examples

Responses

🟢200OK
application/json
Bodyapplication/json

🟠400Bad Request
🟠401Unauthorized
🟠403Forbidden
🟠404Not Found
🟠409Conflict
🟠429Too Many Requests
🔴500Internal Server Error
🔴503Service Unavailable
Request Request Example
Shell
JavaScript
Java
Swift
curl --location 'https://dev-api.ambfairgame.com/gapi/v1/gapi/v1/g/lotto/tickets/create?token=8d0c6a4e2b9f4f1c9a7e3b5d1c2e4f60' \
--header 'Authorization: Bearer 3f9a1c7e5b2d4f6081a3c5e7f9b1d3f5a7c9e1b3d5f7a9c1e3b5d7f9a1c3e5b7' \
--header 'Accept-Language: th' \
--header 'Content-Type: application/json' \
--data '{
    "requestId": "c1b8f0e2-6a4d-4f7e-9b3a-2d5c8e1f0a97",
    "roomId": 1,
    "roundId": "tm64903fa91c2e",
    "items": [
        {
            "betType": "2-BOTTOM",
            "number": "17",
            "amount": 10
        },
        {
            "betType": "3-TOAD",
            "number": "358",
            "amount": 5
        },
        {
            "betType": "1-TOP",
            "number": "9",
            "amount": 20
        }
    ]
}'
Response Response Example
200 - Ticket created
Three lines; the 2-BOTTOM line is on the lucky number.
{
    "code": "0",
    "description": "Success.",
    "traceID": "0f8e2c1a-6b3d-4e5f-9a7b-1c2d3e4f5a6b",
    "data": {
        "betID": "2_1001_tm64903fa91c2e_9f1c0b7a4d2e6f8a1b3c5d7e9f0a2b4c",
        "createdAt": "2026-09-30T08:07:31.482915Z",
        "totalAmount": 35,
        "balance": "965",
        "items": [
            {
                "betType": "2-BOTTOM",
                "number": "17",
                "amount": 10,
                "rate": 360,
                "isLucky": true,
                "potentialWin": 3600
            },
            {
                "betType": "3-TOAD",
                "number": "358",
                "amount": 5,
                "rate": 150,
                "isLucky": false,
                "potentialWin": 750
            },
            {
                "betType": "1-TOP",
                "number": "9",
                "amount": 20,
                "rate": 3,
                "isLucky": false,
                "potentialWin": 60
            }
        ]
    }
}
Modified at 2026-09-30 13:23:45
Previous
Room Event Stream
Next
Inquiry My Tickets
Built with