{
  "openapi": "3.1.0",
  "info": {
    "title": "BetOddsAPI 1X Sportsbook",
    "version": "2026-11-03",
    "description": "Merchant-facing integration contract. API credentials remain server-side. Callback examples and signature verification are documented on the corresponding guide.",
    "contact": {
      "name": "BetOddsAPI integrations",
      "url": "https://t.me/boavix"
    }
  },
  "servers": [
    {
      "url": "https://1x.betapidata.online"
    }
  ],
  "security": [
    {
      "MerchantId": [],
      "ApiKey": [],
      "MerchantDomain": []
    }
  ],
  "paths": {
    "/api/v1/launch": {
      "post": {
        "summary": "Create a single-use 60-second launch ticket",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LaunchResponse"
                }
              }
            }
          },
          "default": {
            "description": "Non-success response; inspect the product-specific error body."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LaunchRequest"
              }
            }
          }
        }
      }
    },
    "/api/v1/stream": {
      "get": {
        "summary": "Resolve a protected stream for an active merchant/player session",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StreamResponse"
                }
              }
            }
          },
          "default": {
            "description": "Non-success response; inspect the product-specific error body."
          }
        },
        "parameters": [
          {
            "name": "eventId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,20}$"
            }
          },
          {
            "name": "playerId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "MerchantId": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Merchant-ID",
        "description": "1X merchant code"
      },
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Private 1X merchant API key"
      },
      "MerchantDomain": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Merchant-Domain",
        "description": "Exact approved player website hostname; outbound IP must also be approved."
      }
    },
    "schemas": {
      "LaunchRequest": {
        "type": "object",
        "properties": {
          "playerId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,100}$",
            "example": "123456"
          },
          "username": {
            "type": "string",
            "maxLength": 100
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "example": "BDT"
          }
        },
        "required": [
          "playerId",
          "currency"
        ],
        "additionalProperties": true
      },
      "LaunchResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          },
          "data": {
            "type": "object",
            "properties": {
              "launchUrl": {
                "type": "string",
                "format": "uri"
              },
              "expiresIn": {
                "type": "integer",
                "const": 60
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$",
                "example": "BDT"
              },
              "mode": {
                "enum": [
                  "test",
                  "production"
                ]
              }
            },
            "required": [
              "launchUrl",
              "expiresIn"
            ],
            "additionalProperties": true
          }
        },
        "required": [
          "ok",
          "data"
        ],
        "additionalProperties": true
      },
      "StreamResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          },
          "data": {
            "type": "object",
            "properties": {
              "eventId": {
                "type": "string"
              },
              "available": {
                "type": "boolean"
              },
              "url": {
                "type": "string",
                "format": "uri",
                "description": "Present when available. Protected session-bound media URL."
              }
            },
            "required": [
              "eventId",
              "available"
            ],
            "additionalProperties": true
          }
        },
        "required": [
          "ok",
          "data"
        ],
        "additionalProperties": true
      },
      "WalletEvent": {
        "type": "object",
        "properties": {
          "action": {
            "enum": [
              "balance",
              "bet",
              "settlement"
            ]
          },
          "transaction_id": {
            "type": "string"
          },
          "player_id": {
            "type": "string"
          },
          "bet_id": {
            "type": "string"
          },
          "event_id": {
            "type": "string"
          },
          "parent_event_id": {
            "type": "string"
          },
          "market_id": {
            "type": "string"
          },
          "selection_id": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "example": "BDT"
          },
          "amount": {
            "type": "number",
            "minimum": 0
          },
          "odds": {
            "type": "number"
          },
          "result": {
            "enum": [
              "won",
              "lost",
              "refund"
            ]
          }
        },
        "required": [
          "action",
          "transaction_id",
          "player_id",
          "currency"
        ],
        "additionalProperties": true
      },
      "WalletResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "boolean"
          },
          "transaction_id": {
            "type": "string",
            "description": "Must exactly match the callback transaction_id."
          },
          "balance": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": [
          "status",
          "transaction_id",
          "balance"
        ],
        "additionalProperties": true
      }
    }
  },
  "externalDocs": {
    "url": "https://docs.betoddsapi.live/1xbet/"
  },
  "webhooks": {
    "wallet": {
      "post": {
        "summary": "Signed 1X wallet callback",
        "security": [],
        "description": "Verify X-1X-Merchant and HMAC-SHA256 of timestamp + dot + exact body using the 1X callback secret. Echo transaction_id in every response. Won settlement amount is full payout including stake; lost is zero; refund returns stake.",
        "parameters": [
          {
            "name": "X-1X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-1X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-1X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WalletEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletResponse"
                }
              }
            }
          }
        }
      }
    }
  }
}
