{
  "openapi": "3.1.0",
  "info": {
    "title": "The AI Visibility Check by HiVis — API",
    "version": "1.0.0",
    "summary": "Free website-readiness check for AI answer engines.",
    "description": "Scores how ready a business website is to be read by AI answer engines, from 0 to 100 with fixed weights, using only public pages (homepage, robots.txt, /llms.txt, sitemap). It does NOT query ChatGPT, Google AI Mode, Gemini, Perplexity, Claude, Copilot or any other AI engine, and does not show whether an engine names the business. Bots and developers need a free API key (POST /api/keys with an email). The same check is available as an MCP server at https://hivisaisolutions.com/mcp (Streamable HTTP, tool `check_ai_visibility`).",
    "contact": {
      "name": "HiVis AI Solutions",
      "email": "hello@hivisaisolutions.com",
      "url": "https://hivisaisolutions.com/ai-visibility-check/developers/"
    },
    "termsOfService": "https://hivisaisolutions.com/terms/"
  },
  "servers": [
    {
      "url": "https://hivisaisolutions.com"
    }
  ],
  "externalDocs": {
    "url": "https://hivisaisolutions.com/ai-visibility-check/developers/",
    "description": "Developer guide"
  },
  "components": {
    "securitySchemes": {
      "bearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Free HiVis API key (starts with hvk_). Get one with POST /api/keys."
      },
      "headerKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        }
      },
      "CheckRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Website homepage. https:// is added if missing.",
            "examples": [
              "https://example.com"
            ]
          },
          "business_name": {
            "type": "string",
            "maxLength": 200,
            "description": "Optional. Used to check the title tag."
          },
          "town": {
            "type": "string",
            "maxLength": 200,
            "description": "Optional. Town and state served, e.g. 'Meriden, CT'. If omitted, the town check is skipped and excluded from the score."
          },
          "service": {
            "type": "string",
            "maxLength": 200,
            "description": "Optional. Main service, used to check the title tag."
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Required only when calling without an API key (the website form)."
          },
          "consent": {
            "type": "boolean",
            "default": false,
            "description": "Website form only: true if the person ticked the optional marketing-email box."
          }
        }
      },
      "CheckResult": {
        "type": "object",
        "properties": {
          "tool": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "checked_url": {
            "type": "string"
          },
          "homepage_url": {
            "type": "string"
          },
          "homepage_ok": {
            "type": "boolean"
          },
          "homepage_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "0–100 website-readiness score. Equals total when maximum is 100; otherwise total/maximum scaled to 100."
          },
          "total": {
            "type": "integer"
          },
          "maximum": {
            "type": "integer"
          },
          "checks": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "earned": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pass",
                    "warn",
                    "fail",
                    "na"
                  ]
                },
                "note": {
                  "type": "string"
                }
              },
              "required": [
                "label",
                "earned",
                "max",
                "status",
                "note"
              ]
            },
            "description": "Keys: https, robots_fetchable, ai_crawlers, sitemap, llms_txt, title, meta_description, h1, phone, address, town_mention, schema_local_business, schema_faq, schema_review, schema_service."
          },
          "crawlers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "bot": {
                  "type": "string"
                },
                "core": {
                  "type": "boolean"
                },
                "allowed": {
                  "type": [
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          },
          "top_fixes": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "points_missed": {
                  "type": "number"
                },
                "status": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                },
                "fix": {
                  "type": "string"
                }
              }
            }
          },
          "signals": {
            "type": "object"
          },
          "disclaimer": {
            "type": "string"
          },
          "checked_at": {
            "type": "string",
            "format": "date-time"
          },
          "next_steps": {
            "type": "object",
            "properties": {
              "free_consultation": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "score",
          "total",
          "maximum",
          "checks",
          "top_fixes",
          "disclaimer"
        ]
      },
      "KeyRequest": {
        "type": "object",
        "required": [
          "email",
          "accept_terms"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "accept_terms": {
            "type": "boolean",
            "const": true,
            "description": "Must be true: you accept https://hivisaisolutions.com/terms/ and https://hivisaisolutions.com/privacy/."
          },
          "marketing_consent": {
            "type": "boolean",
            "default": false,
            "description": "Optional. True to receive occasional tips by email."
          }
        }
      },
      "KeyResponse": {
        "type": "object",
        "properties": {
          "api_key": {
            "type": "string",
            "description": "Shown once. HiVis stores only a hash."
          },
          "key_prefix": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "limits": {
            "type": "object"
          },
          "usage": {
            "type": "object"
          },
          "marketing_consent": {
            "type": "boolean"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid input",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit reached. See Retry-After.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/check": {
      "post": {
        "operationId": "checkAiVisibility",
        "summary": "Run the AI Visibility Check on a website",
        "description": "With an API key: email is not needed; limits are 10 checks per minute and 100 per day per key. Without a key (the website form): email is required; limits are 5 checks per 10 minutes and 20 per day per IP. Reads public pages only; never queries an AI engine.",
        "security": [
          {
            "bearerKey": []
          },
          {
            "headerKey": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckRequest"
              },
              "examples": {
                "bot": {
                  "value": {
                    "url": "https://example.com",
                    "town": "Meriden, CT"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Check result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Backend not configured yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/keys": {
      "post": {
        "operationId": "createApiKey",
        "summary": "Get a free API key in exchange for an email",
        "description": "Limits: 3 new keys per day per IP and 3 active keys per email. The key is returned once.",
        "security": [
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KeyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Key created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "409": {
            "description": "Too many active keys for this email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Service status",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}
