{
  "openapi": "3.1.0",
  "info": {
    "title": "ServPrivacy Agent API",
    "version": "1.0.0",
    "description": "Public REST API for AI agents to discover, price, order and manage anonymous VPS and dedicated servers on servprivacy.com. Crypto-only, no KYC, no email. Bearer auth (auto-issued on first order). Companion MCP server at https://servprivacy.com/mcp. Companion x402-light at the same /orders endpoint via header X-Payment-Mode: x402.",
    "contact": {"email": "contact@servprivacy.com", "url": "https://servprivacy.com/agents"},
    "license": {"name": "Proprietary"}
  },
  "servers": [{"url": "https://servprivacy.com"}],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "AAAA-BBBB-CCCC-DDDD"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": ["ok", "error", "message"],
        "properties": {
          "ok": {"type": "boolean", "const": false},
          "error": {"type": "string", "description": "machine-readable code"},
          "message": {"type": "string"}
        }
      },
      "Plan": {
        "type": "object",
        "properties": {
          "name": {"type": "string", "example": "VPS-M"},
          "cpu": {"type": "string"},
          "proc": {"type": "string"},
          "ram": {"type": "string"},
          "disk": {"type": "string"},
          "bw": {"type": "string"},
          "up": {"type": "string"},
          "prices": {"type": "object", "additionalProperties": {"type": "number"}}
        }
      }
    }
  },
  "paths": {
    "/api/v1/": {
      "get": {
        "summary": "API root — recipe + capabilities",
        "responses": {"200": {"description": "OK"}}
      }
    },
    "/api/v1/catalog": {
      "get": {
        "summary": "Full price/spec matrix (VPS + dedicated, all locations)",
        "responses": {"200": {"description": "Catalog", "content": {"application/json": {"example": {"ok": true, "vps": [], "dedicated": [], "billing_discounts": {"1": 0, "3": 25, "6": 35, "12": 50}}}}}}
      }
    },
    "/api/v1/locations": {
      "get": {
        "summary": "7 jurisdictions with privacy/legal features",
        "responses": {"200": {"description": "Locations"}}
      }
    },
    "/api/v1/quote": {
      "post": {
        "summary": "Calculate final price (with discounts + extras)",
        "requestBody": {"required": true, "content": {"application/json": {"example": {"type": "vps", "plan": "VPS-M", "location": "iceland", "billing": 3, "extra_ips": 0}}}},
        "responses": {"200": {"description": "Quote"}}
      }
    },
    "/api/v1/orders": {
      "post": {
        "summary": "Create an order (auto-creates account if no Bearer)",
        "description": "Send `X-Payment-Mode: x402` to receive a 402 response with USDC instructions in one round trip. Otherwise classic JSON with FF deposit address.",
        "requestBody": {"required": true, "content": {"application/json": {"example": {"type": "vps", "plan": "VPS-M", "location": "iceland", "os": "ubuntu-24", "crypto": "XMR", "billing": 3}}}},
        "responses": {
          "201": {"description": "Order created (classic mode)", "content": {"application/json": {"example": {"ok": true, "order_id": 12345, "order_number": "428193", "server_id": 9876, "account_token": "AAAA-BBBB-CCCC-DDDD", "payment": {"crypto": "XMR", "address": "47abc...", "amount_crypto": "0.4521", "amount_usd": 74.22, "expires_in": 3600}, "status_url": "https://servprivacy.com/api/v1/orders/12345"}}}},
          "402": {"description": "Payment required (x402-light mode)", "headers": {"X-Payment-Required": {"schema": {"type": "string"}}}, "content": {"application/json": {"example": {"error": "payment_required", "x402_light": true, "facilitator": null, "amount": "74.22", "asset": "USDCETH", "recipient": "0xff…", "expires_in": 900, "poll_url": "https://servprivacy.com/api/v1/orders/12345"}}}},
          "400": {"description": "Bad input", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "429": {"description": "Rate limited"},
          "502": {"description": "FixedFloat error"}
        }
      }
    },
    "/api/v1/orders/{id}": {
      "get": {
        "summary": "Get order status (poll until `active`)",
        "security": [{"BearerAuth": []}],
        "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}],
        "responses": {"200": {"description": "Order"}}
      }
    },
    "/api/v1/servers/{id}": {
      "get": {
        "summary": "Get server credentials (once status=active)",
        "security": [{"BearerAuth": []}],
        "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}],
        "responses": {"200": {"description": "Server"}}
      }
    },
    "/api/v1/servers/{id}/action": {
      "post": {
        "summary": "Lifecycle action (reboot/shutdown/start/reinstall/console_link)",
        "security": [{"BearerAuth": []}],
        "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}],
        "requestBody": {"required": true, "content": {"application/json": {"example": {"action": "reboot"}}}},
        "responses": {"200": {"description": "Queued"}}
      }
    },
    "/api/v1/account": {
      "post": {
        "summary": "Create a fresh account (returns Bearer token)",
        "responses": {"201": {"description": "Created", "content": {"application/json": {"example": {"ok": true, "account_token": "AAAA-BBBB-CCCC-DDDD", "prefix": "AAAA"}}}}}
      },
      "get": {
        "summary": "Account info + linked servers",
        "security": [{"BearerAuth": []}],
        "responses": {"200": {"description": "Account"}}
      }
    }
  },
  "x-mcp-server": "https://servprivacy.com/mcp",
  "x-discovery": "https://servprivacy.com/.well-known/agent.json",
  "x-dry-run": {
    "trigger": "Header X-Dry-Run: 1 OR ?dry_run=1 OR body.dry_run=true",
    "behavior": "Synthetic order, fake credentials, 60s auto-confirm. No FF call, no DB row."
  }
}
