{
  "openapi": "3.0.3",
  "info": {
    "title": "USAVerify Pro Developer & Reseller REST API",
    "description": "Enterprise-grade real physical USA Non-VoIP cellular SIM (AT&T, Verizon, T-Mobile) and 180+ worldwide virtual numbers for automated SMS OTP reception, bot pipelines, and reseller panels.",
    "version": "1.2.0",
    "contact": {
      "name": "USAVerify Pro Support & Reseller VIP Desk",
      "url": "https://usaverifypro.com/contact",
      "email": "support@usaverifypro.com"
    }
  },
  "servers": [
    {
      "url": "https://usaverifypro.com/api",
      "description": "Production REST API Server"
    },
    {
      "url": "https://usaverifypro.com",
      "description": "Root Server (SMS-Activate handler_api.php compatibility)"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    },
    {
      "ApiKeyAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Pass your Developer API Key as a Bearer token in the Authorization header (e.g., 'Authorization: Bearer YOUR_API_KEY')."
      },
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Or pass your Developer API Key in the 'X-API-Key' header or '?api_key=' URL parameter."
      }
    },
    "schemas": {
      "UserResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": true },
          "user": {
            "type": "object",
            "properties": {
              "email": { "type": "string", "example": "reseller@example.com" },
              "balance": { "type": "number", "format": "float", "example": 50.25 },
              "currency": { "type": "string", "example": "USD" },
              "api_key": { "type": "string", "example": "uv_live_9a7b8c1d..." },
              "price_multiplier": { "type": "number", "example": 1.0 }
            }
          },
          "orders": { "type": "array", "items": { "type": "object" } }
        }
      },
      "BalanceResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": true },
          "balance": { "type": "number", "format": "float", "example": 50.25 },
          "currency": { "type": "string", "example": "USD" }
        }
      },
      "ServicesListResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": true },
          "total": { "type": "integer", "example": 180 },
          "services": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": { "type": "string", "example": "wa" },
                "name": { "type": "string", "example": "WhatsApp" },
                "price_usd": { "type": "number", "example": 0.75 },
                "price_ngn": { "type": "number", "example": 1200 },
                "price_cny": { "type": "number", "example": 5.45 },
                "available": { "type": "boolean", "example": true },
                "count": { "type": "integer", "example": 450 }
              }
            }
          }
        }
      },
      "OrderRequest": {
        "type": "object",
        "required": ["service"],
        "properties": {
          "service": {
            "type": "string",
            "description": "Service code (e.g. 'wa', 'tg', 'openai', 'go', 'cl')",
            "example": "wa"
          },
          "max_price": {
            "type": "number",
            "description": "Optional maximum USD price willing to pay",
            "example": 1.50
          }
        }
      },
      "OrderResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": true },
          "order_id": { "type": "string", "example": "ORD1730304000" },
          "activation_id": { "type": "string", "example": "1948201" },
          "phone": { "type": "string", "example": "+14159021234" },
          "price_usd": { "type": "number", "example": 0.75 },
          "new_balance": { "type": "number", "example": 49.50 },
          "expiry_secs": { "type": "integer", "example": 1200 }
        }
      },
      "CheckSmsResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": true },
          "status": { "type": "string", "enum": ["waiting", "received", "cancelled"], "example": "received" },
          "code": { "type": "string", "example": "849201" },
          "sms_code": { "type": "string", "example": "849201" },
          "codes": { "type": "array", "items": { "type": "string" }, "example": ["849201"] },
          "number": { "type": "string", "example": "+14159021234" }
        }
      },
      "CancelRequest": {
        "type": "object",
        "required": ["id"],
        "properties": {
          "id": { "type": "string", "description": "Order ID or Activation ID", "example": "ORD1730304000" },
          "status": { "type": "string", "example": "8", "description": "Status 8 triggers cancellation & 100% refund" }
        }
      },
      "CancelResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": true },
          "refunded": { "type": "number", "example": 0.75 },
          "refunded_usd": { "type": "number", "example": 0.75 }
        }
      }
    }
  },
  "paths": {
    "/me": {
      "get": {
        "summary": "Get Account Profile & Live Balance",
        "description": "Returns user profile, permanent API Key, currency preferences, live balance, and recent orders.",
        "responses": {
          "200": {
            "description": "User profile retrieved successfully",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/UserResponse" } }
            }
          },
          "401": { "description": "Unauthorized — invalid or missing API key" }
        }
      }
    },
    "/user/balance": {
      "get": {
        "summary": "Lightweight Real-time Balance Check",
        "description": "Quick balance query endpoint optimized for automated bots and balance monitoring.",
        "responses": {
          "200": {
            "description": "Live balance",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/BalanceResponse" } }
            }
          }
        }
      }
    },
    "/services": {
      "get": {
        "summary": "List USA Non-VoIP Services & Real-time Prices",
        "description": "Returns all available USA physical Non-VoIP cellular services with real-time stock numbers and live prices in USD, NGN, and CNY.",
        "responses": {
          "200": {
            "description": "Services list",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ServicesListResponse" } }
            }
          }
        }
      }
    },
    "/order": {
      "post": {
        "summary": "Rent USA Physical Non-VoIP Number",
        "description": "Rents a real physical cellular line from AT&T, Verizon, or T-Mobile for the chosen service.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": { "schema": { "$ref": "#/components/schemas/OrderRequest" } }
          }
        },
        "responses": {
          "200": {
            "description": "Number allocated successfully",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/OrderResponse" } }
            }
          },
          "400": { "description": "Insufficient balance or no numbers available" }
        }
      }
    },
    "/check_sms": {
      "get": {
        "summary": "Check SMS OTP Delivery Status",
        "description": "Polls the status of an active number rental to retrieve received verification codes. Supports multi-code resends.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "description": "Order ID (e.g. ORD...) or activation ID",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Order status and SMS code payload",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/CheckSmsResponse" } }
            }
          }
        }
      }
    },
    "/cancel": {
      "post": {
        "summary": "Cancel Order & Automated 100% Refund",
        "description": "Releases the line early and triggers an atomic, instant 100% wallet balance refund.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": { "schema": { "$ref": "#/components/schemas/CancelRequest" } }
          }
        },
        "responses": {
          "200": {
            "description": "Order cancelled and balance refunded",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/CancelResponse" } }
            }
          }
        }
      }
    },
    "/mark_done": {
      "post": {
        "summary": "Mark Order as Completed",
        "description": "Confirms successful OTP reception and marks order done.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["activation_id"],
                "properties": {
                  "activation_id": { "type": "string", "example": "1948201" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Order marked completed" }
        }
      }
    },
    "/stubs/handler_api.php": {
      "get": {
        "summary": "SMS-Activate / SMSHub Compatible Protocol",
        "description": "Universal compatibility interface for existing ZennoPoster templates, SMSHub brokers, and third-party SMS reseller bots. Supports actions: getBalance, getNumber, getStatus, setStatus.",
        "parameters": [
          { "name": "api_key", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "action", "in": "query", "required": true, "schema": { "type": "string", "enum": ["getBalance", "getNumber", "getStatus", "setStatus"] } },
          { "name": "service", "in": "query", "required": false, "schema": { "type": "string" } },
          { "name": "country", "in": "query", "required": false, "schema": { "type": "string", "default": "0" } },
          { "name": "id", "in": "query", "required": false, "schema": { "type": "string" } },
          { "name": "status", "in": "query", "required": false, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Plain text SMS-Activate protocol response",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "ACCESS_NUMBER:1948201:14159021234"
                }
              }
            }
          }
        }
      }
    }
  }
}
