{
  "openapi": "3.0.3",
  "info": {
    "title": "Solar Israel agent API",
    "version": "1.1.0",
    "description": "Read-only tools for public solar guides, the site calculator, verified 2026 price facts, and the public company directory. Responses include a source URL and a date. The calculator rate is a site assumption, not the official electricity tariff. This API does not accept leads, reviews, or contact details. A name, phone, or email on /api/agent/consult-link is rejected and is not stored. Every response sends X-Robots-Tag: noindex, nofollow. Each GET also accepts HEAD, which returns the same status and headers with an empty body. Default rate limit: 30 requests per sliding minute and 500 requests per UTC day for each client IP. A blocked call returns 429 with Retry-After, RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, and Cache-Control: private, no-store."
  },
  "servers": [
    { "url": "https://api.solarisrael.co" }
  ],
  "paths": {
    "/api/agent": {
      "get": {
        "operationId": "agent_index",
        "summary": "List the read-only agent tools",
        "responses": {
          "200": {
            "description": "Tool index. openapi and mcp each list the API host and the website host. tools is the full tool list.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AgentIndex" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/agent/guides": {
      "get": {
        "operationId": "search_guides",
        "summary": "Search visible Hebrew solar guides",
        "parameters": [
          { "name": "q", "in": "query", "required": true, "schema": { "type": "string", "minLength": 2, "maxLength": 120 }, "description": "Also accepted as query." },
          { "name": "category", "in": "query", "required": false, "schema": { "type": "string", "maxLength": 80 }, "description": "Optional exact category. Applied together with q." },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 20, "default": 8 } }
        ],
        "responses": {
          "200": { "description": "Matching guides with source_url and updated_at. Hidden guides are omitted." },
          "400": { "description": "Missing or invalid query, or a category that is too long." },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/agent/guides/{slug}": {
      "get": {
        "operationId": "get_guide",
        "summary": "Read one visible guide",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Guide slug. Percent-encoded Hebrew is accepted." }
        ],
        "responses": {
          "200": {
            "description": "Guide fields and content_markdown extracted from articles.content.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/Guide" } }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/agent/estimate": {
      "get": {
        "operationId": "estimate_system",
        "summary": "Estimate a system with the public calculator formulas",
        "parameters": [
          { "name": "roof_sqm", "in": "query", "required": true, "schema": { "type": "number", "minimum": 8, "maximum": 5000 } },
          { "name": "monthly_kwh", "in": "query", "schema": { "type": "number", "minimum": 1, "maximum": 200000 } },
          { "name": "monthly_bill_ils", "in": "query", "schema": { "type": "number", "minimum": 1, "maximum": 200000 }, "description": "Used when monthly_kwh is omitted." },
          { "name": "direction", "in": "query", "schema": { "type": "string", "default": "south", "enum": ["south", "southeast", "southwest", "east", "west", "east-west", "northeast", "northwest", "north", "flat"] } },
          { "name": "residential", "in": "query", "schema": { "type": "boolean", "default": true } },
          { "name": "city", "in": "query", "schema": { "type": "string" }, "description": "Echoed in the result. It does not change the math." }
        ],
        "responses": {
          "200": { "description": "Estimate, assumptions, source URL, and assumption date." },
          "400": { "description": "Invalid input." },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/agent/companies": {
      "get": {
        "operationId": "list_companies",
        "summary": "List visible directory companies",
        "parameters": [
          { "name": "city", "in": "query", "schema": { "type": "string", "maxLength": 40 } },
          { "name": "region", "in": "query", "schema": { "type": "string", "enum": ["צפון", "מרכז", "דרום", "north", "center", "south"] } },
          { "name": "q", "in": "query", "schema": { "type": "string", "maxLength": 80 }, "description": "Search display name, city, and notes." },
          { "name": "min_rating", "in": "query", "schema": { "type": "number", "minimum": 0, "maximum": 5 } },
          { "name": "sort", "in": "query", "schema": { "type": "string", "enum": ["reviews", "rating"], "default": "reviews" } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "minimum": 0, "maximum": 5000, "default": 0 } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 50, "default": 20 } }
        ],
        "responses": {
          "200": {
            "description": "count, total, offset, limit, city, region, source, and public company cards. The directory row has no updated_at column, so card.updated_at is null. photos and email are not selected.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/CompanyList" } }
            }
          },
          "400": { "description": "Invalid region, query, min_rating, sort, or offset." },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/agent/companies/{slug}": {
      "get": {
        "operationId": "get_company",
        "summary": "Read one visible company",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Company slug. Percent-encoded Hebrew is accepted." }
        ],
        "responses": {
          "200": {
            "description": "Public profile plus approved first-party reviews. reviewer_email and reviewer_phone are never returned.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/CompanyProfile" } }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/agent/facts": {
      "get": {
        "operationId": "get_solar_facts",
        "summary": "Verified 2026 price facts and calculator assumptions",
        "responses": {
          "200": {
            "description": "Price rows, Electricity Authority feed-in text, calculator assumptions, source_url, and as_of. Tax ceiling and VAT rate are null when the verified sources do not state them.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/SolarFacts" } }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/agent/consult-link": {
      "get": {
        "operationId": "build_consult_link",
        "summary": "Build a WhatsApp consult link and a site link",
        "description": "Optional roof, bill, and city are added as facts. The WhatsApp text does not name an installer and does not promise a number of quotes. name, phone, and email are rejected.",
        "parameters": [
          { "name": "roof_sqm", "in": "query", "schema": { "type": "number", "minimum": 1, "maximum": 5000 } },
          { "name": "monthly_bill_ils", "in": "query", "schema": { "type": "number", "minimum": 1, "maximum": 200000 } },
          { "name": "city", "in": "query", "schema": { "type": "string", "maxLength": 40 } },
          { "name": "intent", "in": "query", "schema": { "type": "string", "enum": ["home", "business", "general"], "default": "general" } },
          { "name": "agent_name", "in": "query", "schema": { "type": "string" }, "description": "Optional caller label for utm_content. It is not written into the WhatsApp text." },
          { "name": "medium", "in": "query", "schema": { "type": "string", "enum": ["api", "mcp", "llms"], "default": "api" } }
        ],
        "responses": {
          "200": {
            "description": "wa_url, site_url, go_wa_url, and label. go_wa_url is the site handoff at /go/wa.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ConsultLink" } }
            }
          },
          "400": { "description": "Invalid input, or personal data was sent (code pii_rejected). The rejected value is not echoed." },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/mcp": {
      "get": {
        "operationId": "mcp_discovery",
        "summary": "MCP discovery document",
        "responses": {
          "200": { "description": "POST JSON-RPC instructions." },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      },
      "post": {
        "operationId": "mcp_rpc",
        "summary": "MCP JSON-RPC for initialize, tools/list, and tools/call",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object" }
            }
          }
        },
        "responses": {
          "200": { "description": "JSON-RPC result." },
          "202": { "description": "Accepted notification." },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    }
  },
  "components": {
    "responses": {
      "NotFound": {
        "description": "Missing or hidden record.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": ["error"],
              "properties": { "error": { "type": "string", "example": "not found" } }
            }
          }
        }
      },
      "RateLimited": {
        "description": "The client IP exceeded 30 requests in the sliding minute or 500 requests in the UTC day.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before another request.",
            "schema": { "type": "integer", "minimum": 1 }
          },
          "RateLimit-Limit": {
            "description": "Quota of the window that blocked the call.",
            "schema": { "type": "integer" }
          },
          "RateLimit-Remaining": {
            "description": "Remaining requests in that window. Zero when blocked.",
            "schema": { "type": "integer", "example": 0 }
          },
          "RateLimit-Reset": {
            "description": "Seconds until that window allows another request.",
            "schema": { "type": "integer", "minimum": 1 }
          },
          "Cache-Control": {
            "description": "private, no-store",
            "schema": { "type": "string", "example": "private, no-store" }
          }
        },
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/RateLimitedBody" }
          }
        }
      }
    },
    "schemas": {
      "AgentIndex": {
        "type": "object",
        "required": ["name", "read_only", "openapi", "mcp", "llms", "llms_full", "tools"],
        "properties": {
          "name": { "type": "string" },
          "read_only": { "type": "boolean" },
          "openapi": {
            "type": "array",
            "items": { "type": "string", "format": "uri" },
            "minItems": 2
          },
          "mcp": {
            "type": "array",
            "items": { "type": "string", "format": "uri" },
            "minItems": 2
          },
          "llms": { "type": "string", "format": "uri" },
          "llms_full": { "type": "string", "format": "uri" },
          "tools": { "type": "array", "items": { "type": "object" } }
        }
      },
      "Guide": {
        "type": "object",
        "required": ["title", "slug", "category", "summary", "content_markdown", "published_at", "updated_at", "source_url", "markdown_url"],
        "properties": {
          "title": { "type": "string" },
          "slug": { "type": "string" },
          "category": { "type": "string" },
          "summary": { "type": "string" },
          "content_markdown": { "type": "string" },
          "published_at": { "type": ["string", "null"] },
          "updated_at": { "type": ["string", "null"] },
          "source_url": { "type": "string", "format": "uri" },
          "markdown_url": { "type": "string", "format": "uri" }
        }
      },
      "CompanyCard": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "slug": { "type": "string" },
          "city": { "type": "string" },
          "region": { "type": "string" },
          "phone": { "type": "string" },
          "website": { "type": "string" },
          "rating": { "type": "number" },
          "review_count": { "type": "number" },
          "description": { "type": "string" },
          "source_url": { "type": "string" },
          "updated_at": { "type": "null" }
        }
      },
      "CompanyList": {
        "type": "object",
        "required": ["count", "total", "offset", "limit", "city", "region", "source", "results"],
        "properties": {
          "count": { "type": "integer" },
          "total": { "type": "integer" },
          "offset": { "type": "integer" },
          "limit": { "type": "integer" },
          "city": { "type": ["string", "null"] },
          "region": { "type": ["string", "null"] },
          "source": { "type": "object" },
          "results": { "type": "array", "items": { "$ref": "#/components/schemas/CompanyCard" } }
        }
      },
      "CompanyReview": {
        "type": "object",
        "required": ["reviewer_display_name", "rating_overall", "title", "body", "created_at", "installation_type", "system_size_kwp", "installation_year"],
        "properties": {
          "reviewer_display_name": { "type": "string" },
          "rating_overall": { "type": ["integer", "null"] },
          "title": { "type": "string" },
          "body": { "type": "string" },
          "created_at": { "type": ["string", "null"] },
          "installation_type": { "type": ["string", "null"] },
          "system_size_kwp": { "type": ["number", "null"] },
          "installation_year": { "type": ["integer", "null"] }
        }
      },
      "CompanyProfile": {
        "type": "object",
        "required": ["name", "slug", "city", "region", "address", "phone", "website", "company_type", "opening_hours", "description", "google_rating", "google_review_count", "reviews", "source_url", "markdown_url"],
        "properties": {
          "name": { "type": "string" },
          "slug": { "type": "string" },
          "city": { "type": "string" },
          "region": { "type": "string" },
          "address": { "type": "string" },
          "phone": { "type": "string" },
          "website": { "type": "string" },
          "company_type": { "type": "array", "items": { "type": "string" } },
          "opening_hours": { "type": "array", "items": { "type": "string" } },
          "description": { "type": "string" },
          "google_rating": { "type": ["number", "null"] },
          "google_review_count": { "type": ["number", "null"] },
          "reviews": { "type": "array", "items": { "$ref": "#/components/schemas/CompanyReview" } },
          "source_url": { "type": "string" },
          "markdown_url": { "type": "string" }
        }
      },
      "SolarFacts": {
        "type": "object",
        "required": ["as_of", "source_url", "pricing", "feed_in_tariffs", "household_tax_exemption", "vat", "calculator"],
        "properties": {
          "as_of": { "type": "string" },
          "source_url": { "type": "string" },
          "pricing": { "type": "object" },
          "feed_in_tariffs": { "type": "object" },
          "household_tax_exemption": {
            "type": "object",
            "properties": {
              "ceiling_ils": { "type": "null" },
              "tracks": { "type": "array", "items": { "type": "string" } },
              "note": { "type": "string" }
            }
          },
          "vat": {
            "type": "object",
            "properties": {
              "rate": { "type": "null" },
              "note": { "type": "string" }
            }
          },
          "calculator": { "type": "object" }
        }
      },
      "ConsultLink": {
        "type": "object",
        "required": ["wa_url", "site_url", "go_wa_url", "label"],
        "properties": {
          "wa_url": { "type": "string", "format": "uri" },
          "site_url": { "type": "string", "format": "uri" },
          "go_wa_url": { "type": "string", "format": "uri" },
          "label": { "type": "string", "example": "לייעוץ וקבלת הצעה 24/7" }
        }
      },
      "RateLimitedBody": {
        "type": "object",
        "required": ["error", "code"],
        "properties": {
          "error": { "type": "string", "example": "Too many requests" },
          "code": { "type": "string", "example": "rate_limited" }
        }
      }
    }
  }
}
