{
  "openapi": "3.1.0",
  "info": {
    "title": "City Seamless Agent API",
    "version": "0.1.0",
    "description": "Prototype API for agent-readable services and structured rain gutter bid requests."
  },
  "servers": [
    {
      "url": "https://cityseamless.com",
      "description": "Production target"
    }
  ],
  "paths": {
    "/api/bid-request": {
      "post": {
        "operationId": "createBidRequest",
        "summary": "Create a structured rain gutter bid request",
        "description": "Collects contact and job context for City Seamless review. Does not book an install date or quote a price.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BidRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Bid request accepted for internal review",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BidRequestResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing required request fields"
          }
        }
      }
    },
    "/api/agent-answer": {
      "post": {
        "operationId": "answerCitySeamlessQuestion",
        "summary": "Ask the City Seamless site agent a business/service question",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["question"],
                "properties": {
                  "question": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Prototype grounded answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "answer": { "type": "string" },
                    "sources": {
                      "type": "array",
                      "items": { "type": "string" }
                    },
                    "safe_next_action": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "citySeamlessMcp",
        "summary": "Prototype JSON-RPC MCP endpoint",
        "description": "Provides discovery and tool-call shape for City Seamless agent actions.",
        "responses": {
          "200": {
            "description": "JSON-RPC response"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BidRequest": {
        "type": "object",
        "required": ["name", "phone", "email", "city", "service"],
        "properties": {
          "name": { "type": "string" },
          "phone": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "address": { "type": "string" },
          "city": { "type": "string" },
          "state": { "type": "string", "default": "NV" },
          "service": {
            "type": "string",
            "enum": ["rain gutter estimate", "gutter repair", "gutter guards", "copper gutters", "commercial gutters"]
          },
          "preferred_window": { "type": "string" },
          "notes": { "type": "string" },
          "source": { "type": "string" },
          "gclid": { "type": "string" },
          "agent_context": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "BidRequestResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "const": "accepted" },
          "request_id": { "type": "string" },
          "message": { "type": "string" },
          "next_step": { "type": "string" }
        }
      }
    }
  }
}
