{
  "openapi": "3.1.0",
  "info": {
    "title": "AliEV Agent Gateway",
    "version": "1.0.0",
    "description": "Machine-readable EV infrastructure opportunity screening with explicit evidence semantics and a human-confirmed commercial boundary."
  },
  "servers": [
    {
      "url": "https://base44.app"
    }
  ],
  "externalDocs": {
    "description": "AliEV agent documentation",
    "url": "https://aliev.base44.app/agents.html"
  },
  "paths": {
    "/api/apps/69b9b64d86a732029ce0db81/functions/alievAgentGateway": {
      "post": {
        "operationId": "alievAgentGateway",
        "summary": "Discover AliEV capabilities, inspect offers, or screen an EV site",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CapabilitiesRequest"
                  },
                  {
                    "$ref": "#/components/schemas/OffersRequest"
                  },
                  {
                    "$ref": "#/components/schemas/SiteScreenRequest"
                  },
                  {
                    "$ref": "#/components/schemas/HandoffRequest"
                  }
                ]
              },
              "examples": {
                "screenSite": {
                  "value": {
                    "action": "analyze_site",
                    "address": "333 Strander Blvd, Tukwila, WA 98188"
                  }
                },
                "capabilities": {
                  "value": {
                    "action": "capabilities"
                  }
                },
                "offers": {
                  "value": {
                    "action": "offers"
                  }
                },
                "paidHandoff": {
                  "value": {
                    "action": "create_handoff",
                    "offer_key": "site_report_299",
                    "address": "333 Strander Blvd, Tukwila, WA 98188"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "AliEV machine-readable response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsupported request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "502": {
            "description": "Upstream evidence source or site lookup failure",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CapabilitiesRequest": {
        "type": "object",
        "properties": {
          "action": {
            "const": "capabilities"
          }
        },
        "required": [
          "action"
        ],
        "additionalProperties": false
      },
      "OffersRequest": {
        "type": "object",
        "properties": {
          "action": {
            "const": "offers"
          }
        },
        "required": [
          "action"
        ],
        "additionalProperties": false
      },
      "HandoffRequest": {
        "type": "object",
        "properties": {
          "action": {"const": "create_handoff"},
          "offer_key": {"type": "string", "enum": ["site_report_299","site_report_750","opportunity_pack_250","territory_feed_2500_monthly"]},
          "address": {"type": "string", "maxLength": 500},
          "request_id": {"type": "string", "maxLength": 100}
        },
        "required": ["action","offer_key"],
        "additionalProperties": false
      },
      "SiteScreenRequest": {
        "type": "object",
        "properties": {
          "action": {
            "const": "analyze_site"
          },
          "address": {
            "type": "string",
            "minLength": 5,
            "maxLength": 500,
            "description": "Street address or sufficiently specific place address to screen."
          }
        },
        "required": [
          "action",
          "address"
        ],
        "additionalProperties": false
      }
    }
  }
}