{
  "openapi": "3.1.0",
  "info": {
    "title": "Catmouse Anti-Bot Protocol Solver API",
    "version": "1.0.0",
    "description": "High-speed HTTP protocol solver API for enterprise anti-bot defenses (Kasada, Akamai BMP, DataDome, Cloudflare Turnstile). Eliminates headless browsers by computing cryptographic proof-of-work nonces and evaluating virtual machine bytecode in sub-80ms native runtimes.",
    "contact": {
      "name": "Catmouse Engineering",
      "url": "https://catmouse.ai",
      "email": "support@catmouse.ai"
    },
    "license": {
      "name": "Proprietary Commercial API",
      "url": "https://catmouse.ai/legal.html"
    }
  },
  "servers": [
    {
      "url": "https://kasadaapi.catmouse.ai",
      "description": "Production Global Anycast Cluster"
    }
  ],
  "paths": {
    "/Solver/solve": {
      "post": {
        "summary": "Solve Anti-Bot Challenge",
        "description": "Resolves client-side virtual machine challenge telemetry and computes cryptographic proof-of-work nonces. Returns verified HTTP request headers (x-kpsdk-ct, x-kpsdk-cd, x-kpsdk-v) and session cookies (KP_UIDz) ready to inject directly into high-speed HTTP clients.",
        "operationId": "solveChallenge",
        "security": [
          { "ApiKeyAuth": [] }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SolveRequest"
              },
              "example": {
                "engine": "kasada_ips",
                "host": "www.scheels.com",
                "targetUrl": "https://www.scheels.com/p/nike-air-max/12345.html",
                "method": "GET"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Challenge solved successfully with fresh authorization tokens.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SolveResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid payload parameters or unsupported protection engine."
          },
          "401": {
            "description": "Missing or unauthorized API key."
          },
          "402": {
            "description": "insufficient_balance: the key's USD balance cannot cover this call. Top up your USD balance."
          },
          "429": {
            "description": "Account rate limit or concurrency limit exceeded."
          }
        }
      }
    },
    "/Solver/cd": {
      "post": {
        "summary": "Generate Dynamic Challenge Payload (CD)",
        "description": "Synthesizes secondary client dynamic proof payload (x-kpsdk-cd) for rapid consecutive requests and checkout actions.",
        "operationId": "generateCdPayload",
        "security": [
          { "ApiKeyAuth": [] }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["host"],
                "properties": {
                  "host": { "type": "string", "example": "www.scheels.com" },
                  "action": { "type": "string", "example": "checkout" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dynamic payload generated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "solved" },
                    "cdHeader": { "type": "string" },
                    "durationMs": { "type": "number", "example": 14 }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/Solver/getBalance": {
      "get": {
        "summary": "Check USD Balance",
        "description": "Returns the key's spendable USD balance (balanceUsd, balanceMicroUsd) or unlimited=true (both balance fields null), plus the effective per-solve price.",
        "operationId": "checkBalance",
        "security": [
          { "ApiKeyAuth": [] }
        ],
        "responses": {
          "200": {
            "description": "Account balance details.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "unlimited": { "type": "boolean", "example": false },
                    "balanceUsd": { "type": ["number", "null"], "example": 450.5 },
                    "balanceMicroUsd": { "type": ["integer", "null"], "example": 450500000 },
                    "costPerSolveUsd": { "type": "number", "example": 0.003 },
                    "costPer1kUsd": { "type": "number", "example": 3.0 },
                    "usageCount": { "type": "integer", "example": 885 }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/key/billing/oxprocessing/checkout": {
      "post": {
        "summary": "Create Crypto Top-Up Invoice",
        "description": "Initiates an instant, zero-KYC crypto top-up via 0xProcessing. Supports USDT (TRC20, SOL, Polygon, BSC), Bitcoin, Ethereum, Solana, and Binance Pay.",
        "operationId": "createCryptoCheckout",
        "security": [
          { "ApiKeyAuth": [] }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["amountUsd"],
                "properties": {
                  "amountUsd": { "type": "number", "minimum": 10, "example": 100 },
                  "currency": { "type": "string", "enum": ["USDT_TRC20", "USDT_SOL", "USDT_POLYGON", "USDT_BSC", "BTC", "ETH", "SOL", "BINANCE_PAY"], "default": "USDT_TRC20" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoice created successfully with deposit address and checkout URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "paymentId": { "type": "string" },
                    "checkoutUrl": { "type": "string" },
                    "address": { "type": "string" },
                    "network": { "type": "string" },
                    "amountExpected": { "type": "number" },
                    "expiresAt": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/status.json": {
      "get": {
        "summary": "Platform Health & Pass Rate Telemetry",
        "description": "Public health status endpoint returning real-time pass rates, p50/p95 solve latencies, and service availability across all supported anti-bot engines.",
        "operationId": "getPlatformStatus",
        "responses": {
          "200": {
            "description": "Platform status payload.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "operational" },
                    "uptimePct": { "type": "number", "example": 99.98 },
                    "averageSolveMs": { "type": "number", "example": 74.2 },
                    "engines": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "status": { "type": "string" },
                          "passRate": { "type": "number" },
                          "latencyMs": { "type": "number" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Catmouse API key (e.g. ksk_live_...)"
      }
    },
    "schemas": {
      "SolveRequest": {
        "type": "object",
        "required": ["engine", "host", "targetUrl"],
        "properties": {
          "engine": {
            "type": "string",
            "enum": ["kasada_ips", "akamai_bmp", "datadome", "turnstile", "funcaptcha"],
            "description": "Target anti-bot protection system."
          },
          "host": {
            "type": "string",
            "description": "Target hostname (e.g. 'www.scheels.com')."
          },
          "targetUrl": {
            "type": "string",
            "description": "Full target endpoint URL to execute requests against."
          },
          "method": {
            "type": "string",
            "enum": ["GET", "POST", "PUT", "PATCH", "DELETE"],
            "default": "GET"
          },
          "proxy": {
            "type": "string",
            "description": "Optional egress proxy URL for Bring Your Own Proxy (BYOP) routing."
          }
        }
      },
      "SolveResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "solved"
          },
          "engine": {
            "type": "string",
            "example": "kasada_ips"
          },
          "solveDurationMs": {
            "type": "number",
            "example": 72.4
          },
          "headers": {
            "type": "object",
            "description": "Mandatory request headers to inject into your HTTP client.",
            "properties": {
              "x-kpsdk-ct": { "type": "string" },
              "x-kpsdk-cd": { "type": "string" },
              "x-kpsdk-v": { "type": "string" }
            }
          },
          "cookies": {
            "type": "object",
            "description": "Session cookies required by target CDN edge.",
            "properties": {
              "KP_UIDz": { "type": "string" }
            }
          }
        }
      }
    }
  }
}
