{
  "openapi": "3.0.0",
  "info": {
    "title": "GEOScope API",
    "description": "Generative Engine Optimization (GEO) & AI Search Diagnostic Engine. Real-time audit of AI bot firewalls, SSR vs CSR blindspots, RAG chunking answerability, and 1-click /llms.txt and JSON-LD remediation.",
    "version": "1.0.0",
    "contact": {
      "name": "AgentLabs Support",
      "url": "https://geoscope.agentlabs.workers.dev"
    }
  },
  "servers": [
    {
      "url": "https://geoscope.agentlabs.workers.dev",
      "description": "Production Cloudflare Edge Server"
    },
    {
      "url": "http://localhost:3001",
      "description": "Local Development Server"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Service Health Check",
        "description": "Returns operational status and active endpoints.",
        "responses": {
          "200": {
            "description": "Service is healthy and ready for queries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ONLINE"
                    },
                    "service": {
                      "type": "string",
                      "example": "GEOScope API"
                    },
                    "version": {
                      "type": "string",
                      "example": "1.0.0"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/geo-audit": {
      "get": {
        "summary": "Execute Full GEO & AI Search Audit (GET)",
        "description": "Runs comprehensive AI bot handshake simulations, SSR vs CSR evaluation, RAG chunking analysis, and generates 1-click remediation code.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "Target website domain or URL (e.g. 'stripe.com' or 'https://github.com')",
            "schema": {
              "type": "string",
              "example": "https://stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful GEO diagnostic audit report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeoAuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid URL parameter"
          },
          "500": {
            "description": "Audit execution error"
          }
        }
      },
      "post": {
        "summary": "Execute Full GEO Audit (POST)",
        "description": "Submits target URL inside JSON payload for bulk automated workflows.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "example": "https://stripe.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful GEO diagnostic audit report"
          }
        }
      }
    },
    "/v1/audit/bots": {
      "get": {
        "summary": "AI Bot Firewall Audit",
        "description": "Checks robots.txt and WAF rules across 10 major AI search crawlers (ChatGPT, Perplexity, Claude, Gemini, Meta, Cohere, etc.).",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Bot firewall audit report"
          }
        }
      }
    },
    "/v1/audit/rendering": {
      "get": {
        "summary": "SSR vs CSR Blindspot Audit",
        "description": "Detects client-side JavaScript rendering traps and measures extractable text weight.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rendering audit report"
          }
        }
      }
    },
    "/v1/audit/rag-chunking": {
      "get": {
        "summary": "RAG 500-Token Chunking Audit",
        "description": "Simulates semantic vector chunks and verifies Answer-First definition density.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "RAG chunking audit report"
          }
        }
      }
    },
    "/v1/audit/schema": {
      "get": {
        "summary": "Schema.org & /llms.txt Entity Audit",
        "description": "Validates structured JSON-LD entity triples and markdown manifest readiness.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Schema entity audit report"
          }
        }
      }
    },
    "/v1/generate/llms-txt": {
      "post": {
        "summary": "Generate Compliant /llms.txt",
        "description": "Produces a compliant markdown documentation manifest for AI crawlers.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string",
                    "example": "example.com"
                  },
                  "title": {
                    "type": "string",
                    "example": "Example Corp"
                  },
                  "description": {
                    "type": "string",
                    "example": "Developer API tools"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated llms.txt snippet"
          }
        }
      }
    },
    "/v1/generate/schema": {
      "post": {
        "summary": "Generate JSON-LD Entity Schema",
        "description": "Produces compliant Schema.org Organization markup with embedded HTML script tag.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string",
                    "example": "example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated JSON-LD snippet"
          }
        }
      }
    },
    "/v1/generate/robots-txt": {
      "post": {
        "summary": "Generate AI-Optimized robots.txt",
        "description": "Produces an explicit whitelist allowing major AI search engines while protecting sensitive routes.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string",
                    "example": "example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated robots.txt snippet"
          }
        }
      }
    },
    "/v1/pro/retrieval-matrix": {
      "get": {
        "summary": "Pro: Engine Retrieval Matrix",
        "description": "Retrieves engine-by-engine citation probabilities for ChatGPT Search, Perplexity, Claude, and Google AI Overviews.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Engine retrieval matrix"
          }
        }
      }
    },
    "/v1/pro/narrative-rewrites": {
      "get": {
        "summary": "Pro: 45-Word Answer-First Rewrites",
        "description": "Generates dynamic 45-word micro-abstracts tailored specifically for 500-token RAG retrieval windows.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Narrative rewrites"
          }
        }
      }
    },
    "/v1/pro/dossier": {
      "get": {
        "summary": "Pro: Executive C-Suite Strategic Dossier",
        "description": "Complete strategic report combining matrix, dynamic rewrites, competitive percentile benchmarking, and 30-day remediation roadmap.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Complete Pro executive dossier"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "GeoAuditResponse": {
        "type": "object",
        "properties": {
          "target": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "example": "https://stripe.com"
              },
              "hostname": {
                "type": "string",
                "example": "stripe.com"
              },
              "status_code": {
                "type": "integer",
                "example": 200
              }
            }
          },
          "geo_scorecard": {
            "type": "object",
            "properties": {
              "overall_score": {
                "type": "integer",
                "example": 88
              },
              "grade": {
                "type": "string",
                "example": "A"
              },
              "bot_access_score": {
                "type": "integer",
                "example": 100
              },
              "rendering_score": {
                "type": "integer",
                "example": 95
              },
              "rag_answerability_score": {
                "type": "integer",
                "example": 80
              },
              "schema_readiness_score": {
                "type": "integer",
                "example": 70
              }
            }
          },
          "one_click_remediation": {
            "type": "object",
            "properties": {
              "llms_txt": {
                "type": "string"
              },
              "json_ld_schema": {
                "type": "string"
              },
              "ai_robots_txt": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}