{
  "openapi": "3.1.0",
  "info": {
    "title": "Provably Fair Game Provider API",
    "version": "0.1.0"
  },
  "paths": {
    "/health": {
      "get": {
        "summary": "Return runtime health and supported currency contract",
        "responses": {
          "200": { "description": "Health payload returned" }
        }
      }
    },
    "/ready": {
      "get": {
        "summary": "Return deployment readiness for a configured operator",
        "parameters": [
          { "name": "operatorId", "in": "query", "required": false, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Readiness checks passed" },
          "503": { "description": "Readiness checks failed" }
        }
      }
    },
    "/sandbox/launch": {
      "post": {
        "summary": "Create a local sandbox launch token and launch URL",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["operatorId", "playerRef", "gameType"],
                "properties": {
                  "operatorId": { "type": "string" },
                  "playerRef": { "type": "string" },
                  "gameType": { "enum": ["dice", "limbo", "plinko"] },
                  "launchMode": { "enum": ["single", "lobby"], "default": "single" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Sandbox launch payload returned" }
        }
      }
    },
    "/api/sessions": {
      "post": {
        "summary": "Create a game session from a casino launch token",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["operatorId", "launchToken"],
                "properties": {
                  "operatorId": { "type": "string" },
                  "launchToken": { "type": "string" },
                  "gameType": { "enum": ["dice", "limbo", "plinko"], "default": "dice" },
                  "launchMode": { "enum": ["single", "lobby"], "default": "single" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Session created" }
        }
      }
    },
    "/api/balance": {
      "get": {
        "summary": "Fetch current casino-provided balance for a game session",
        "parameters": [
          { "name": "sessionId", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Balance returned" }
        }
      }
    },
    "/api/bets": {
      "post": {
        "summary": "Place a backend-authoritative provably fair bet",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sessionId", "gameType", "amount", "idempotencyKey"],
                "properties": {
                  "sessionId": { "type": "string" },
                  "gameType": { "enum": ["dice", "limbo", "plinko"] },
                  "amount": { "type": "number" },
                  "idempotencyKey": { "type": "string" },
                  "clientSeed": { "type": "string" },
                  "params": { "type": "object" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Bet settled or an identical retry replayed" },
          "400": { "description": "Validation or idempotency conflict" }
        }
      }
    },
    "/api/bets/{roundId}": {
      "get": {
        "summary": "Return a stored round with fairness proof and casino callback audit",
        "parameters": [
          { "name": "roundId", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Round returned" },
          "400": { "description": "Round not found" }
        }
      }
    },
    "/api/verify": {
      "post": {
        "summary": "Verify a previous game result after server seed reveal",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["gameType", "serverSeed", "serverSeedHash", "clientSeed", "nonce", "amount"],
                "properties": {
                  "gameType": { "enum": ["dice", "limbo", "plinko"] },
                  "serverSeed": { "type": "string" },
                  "serverSeedHash": { "type": "string" },
                  "clientSeed": { "type": "string" },
                  "nonce": { "type": "number" },
                  "amount": { "type": "number" },
                  "currency": { "enum": ["USD", "EUR", "GBP", "USDT", "USDC", "BTC", "uBTC", "ETH", "LTC", "DOGE", "BNB", "SOL", "XRP", "ADA", "TRX", "XLM", "ZEC"], "default": "USD" },
                  "params": { "type": "object" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Recalculated result" }
        }
      }
    },
    "/api/reconciliation": {
      "get": {
        "summary": "Return casino wallet transaction reconciliation rows",
        "responses": {
          "200": { "description": "Reconciliation rows" }
        }
      }
    },
    "/api/fairness/rotate": {
      "post": {
        "summary": "Rotate the current server seed and reveal the previous server seed",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sessionId"],
                "properties": {
                  "sessionId": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "New seed hash and revealed previous seed returned" }
        }
      }
    }
  }
}
