{
  "openapi": "3.1.0",
  "info": {
    "title": "HSC Shop Reseller API",
    "version": "1.0.0",
    "description": "Server-to-server API for reselling HSC accounts (OnlyFans balance loads, HSC Bomber keys, ExpressVPN accounts). Authenticate with an X-API-Key header issued from the HSC dashboard. Orders draw against the key owner's balance and refund automatically on delivery failure.",
    "contact": {
      "name": "HSC Support",
      "url": "https://t.me/HSCAgentBot"
    }
  },
  "servers": [
    { "url": "https://api.hotschool.club/v1", "description": "Production" }
  ],
  "security": [{ "ApiKeyAuth": [] }],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Personal API key issued from the HSC dashboard. Anyone holding it can drain your balance — treat as secret."
      }
    },
    "schemas": {
      "OrderStatus": {
        "type": "string",
        "enum": ["processing", "completed", "failed"]
      },
      "OrderResult": {
        "type": "object",
        "description": "Delivered credentials — present only when status = completed",
        "properties": {
          "email":    { "type": "string", "format": "email" },
          "password": { "type": "string" },
          "balance":  { "type": "number" }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "order_id": { "type": "string", "example": "a1b2c3d4" },
          "amount":   { "type": "integer", "enum": [10, 20, 50, 100, 200, 400] },
          "cost":     { "type": "number", "example": 3.98 },
          "status":   { "$ref": "#/components/schemas/OrderStatus" },
          "result":   { "$ref": "#/components/schemas/OrderResult" },
          "error":    { "type": "string" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error":   { "type": "string" },
          "balance": { "type": "number", "description": "Present on 402 Insufficient balance" }
        }
      }
    }
  },
  "paths": {
    "/generate": {
      "post": {
        "operationId": "createOrder",
        "summary": "Fire an OnlyFans balance-loaded account order",
        "description": "Async — poll GET /order/{id} until status is completed or failed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["amount"],
                "properties": {
                  "amount": { "type": "integer", "enum": [10, 20, 50, 100, 200, 400], "description": "USD balance tier" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Order accepted", "content": { "application/json": { "schema": { "type": "object", "properties": { "order_id": { "type": "string" }, "status": { "type": "string", "enum": ["processing"] } } } } } },
          "401": { "description": "Missing/invalid X-API-Key" },
          "402": { "description": "Insufficient balance",   "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "409": { "description": "Tier temporarily out of stock" }
        }
      }
    },
    "/order/{id}": {
      "get": {
        "operationId": "getOrder",
        "summary": "Poll an order status + credentials",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": {
          "200": { "description": "Current order state", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Order" } } } },
          "401": { "description": "Missing/invalid X-API-Key" },
          "404": { "description": "Order not found or not yours" }
        }
      }
    },
    "/balance": {
      "get": {
        "operationId": "getBalance",
        "summary": "Current account balance",
        "responses": {
          "200": { "description": "Balance", "content": { "application/json": { "schema": { "type": "object", "properties": { "balance": { "type": "number" } } } } } }
        }
      }
    },
    "/prices": {
      "get": {
        "operationId": "getPrices",
        "summary": "Per-tier prices",
        "responses": {
          "200": { "description": "Prices in USD", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": { "type": "number" } } } } }
        }
      }
    },
    "/stock": {
      "get": {
        "operationId": "getStock",
        "summary": "Per-tier availability",
        "responses": {
          "200": { "description": "Stock", "content": { "application/json": { "schema": { "type": "object", "properties": { "stock": { "type": "object", "additionalProperties": { "type": "string" } } } } } } }
        }
      }
    },
    "/history": {
      "get": {
        "operationId": "getHistory",
        "summary": "Your full order history",
        "responses": {
          "200": { "description": "Orders keyed by order_id", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": { "$ref": "#/components/schemas/Order" } } } } }
        }
      }
    },
    "/replacement": {
      "post": {
        "operationId": "createReplacement",
        "summary": "Warranty replacement for a delivered order",
        "description": "10-min cooldown from delivery, 120-min warranty window, streak cap 2/tier. Single-use per original.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object", "required": ["order_id"], "properties": { "order_id": { "type": "string", "example": "of-a1b2c3d4" } } }
            }
          }
        },
        "responses": {
          "200": { "description": "Replacement processing or stock-out credited", "content": { "application/json": { "schema": { "type": "object", "properties": { "original": { "type": "string" }, "new_order_id": { "type": "string" }, "status": { "type": "string", "enum": ["processing", "stock_out_credited"] }, "credited_amount": { "type": "number" } } } } } },
          "400": { "description": "expired_window / already_replaced" },
          "404": { "description": "not_found" },
          "429": { "description": "cooldown / streak_cap" }
        }
      }
    },
    "/misc/buy": {
      "post": {
        "operationId": "createMiscOrder",
        "summary": "Buy an HSC Bomber key or ExpressVPN account",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["product_id", "variant_id"],
                "properties": {
                  "product_id": { "type": "string", "enum": ["emailbomber", "expressvpn"] },
                  "variant_id": { "type": "string", "description": "emailbomber: 1day / 7days / 30days / lifetime — expressvpn: 1m / 6m / 1y / lifetime" },
                  "qty":        { "type": "integer", "default": 1 }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Delivered instantly — account in `account` field" }
        }
      }
    },
    "/misc/stock":  { "get": { "operationId": "getMiscStock",  "summary": "Bomber + VPN variant availability", "responses": { "200": { "description": "Stock" } } } },
    "/misc/prices": { "get": { "operationId": "getMiscPrices", "summary": "Bomber + VPN variant prices",       "responses": { "200": { "description": "Prices" } } } }
  }
}
