{
  "openapi": "3.1.0",
  "info": {
    "title": "HrefGate",
    "version": "0.1.1",
    "description": "Lint hreflang annotations (codes, x-default, self-reference, canonical, duplicates, return links). Never fetches URLs. Free: about 30/min per IP, shared daily pool about 20000. Language, script and region codes follow the public ISO 639, ISO 15924 and ISO 3166-1 standards. HrefGate is not affiliated with or endorsed by Google or any search engine.",
    "contact": {
      "email": "digitalpromohub.support@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://hrefgate.mike-tusa.workers.dev"
    }
  ],
  "paths": {
    "/api/lint": {
      "post": {
        "operationId": "lintHreflang",
        "summary": "Lint hreflang annotations in page HTML, a sitemap or a JSON set",
        "parameters": [
          {
            "name": "page_url",
            "in": "query",
            "required": false,
            "description": "Absolute http(s) URL of the pasted HTML page (never fetched)",
            "schema": {
              "type": "string",
              "maxLength": 2048,
              "pattern": "^https?://"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/xml": {
              "schema": {
                "type": "string",
                "maxLength": 65536
              }
            },
            "text/html": {
              "schema": {
                "type": "string",
                "maxLength": 65536
              }
            },
            "text/plain": {
              "schema": {
                "type": "string",
                "maxLength": 65536
              }
            },
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "input": {
                        "type": "string",
                        "maxLength": 65536
                      },
                      "page_url": {
                        "type": "string",
                        "maxLength": 2048
                      }
                    },
                    "required": [
                      "input"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "description": "JSON set {\"pages\":[{\"url\",\"canonical\",\"alternates\":[{\"hreflang\",\"href\"}]}]}"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lint report",
            "headers": {
              "X-HrefGate-Quota-Remaining": {
                "schema": {
                  "type": "string"
                },
                "description": "Approximate checks left in the shared daily pool"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          },
          "400": {
            "description": "invalid_input: empty input, bad page_url, or JSON nested deeper than 32 levels (rejected before rate limits or the daily pool are charged)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "too_large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited or daily_limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "lintGetNotAllowed",
        "summary": "Not supported (content must not go in URLs)",
        "responses": {
          "405": {
            "description": "method_not_allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/mcp/server-card.json": {
      "get": {
        "operationId": "serverCard",
        "summary": "Static MCP server card (same tools as tools/list)",
        "responses": {
          "200": {
            "description": "Server card",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Health and version",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "version": {
                      "type": "string"
                    },
                    "day": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcp",
        "summary": "Remote MCP server (JSON-RPC 2.0 over Streamable HTTP, stateless)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "JSON-RPC 2.0 request, notification or batch (max 10, at most one tools/call)"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "JSON-RPC 2.0 response (or batch array)"
                }
              }
            }
          },
          "202": {
            "description": "Notification or client response accepted (empty body)"
          },
          "400": {
            "description": "Parse error, invalid request or protocol/header mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "JSON-RPC 2.0 response (or batch array)"
                }
              }
            }
          },
          "403": {
            "description": "Origin not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "JSON-RPC 2.0 response (or batch array)"
                }
              }
            }
          },
          "404": {
            "description": "Method not found (2026-07-28 requests)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "JSON-RPC 2.0 response (or batch array)"
                }
              }
            }
          },
          "413": {
            "description": "Body too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "JSON-RPC 2.0 response (or batch array)"
                }
              }
            }
          },
          "429": {
            "description": "Too many MCP requests (Retry-After)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "JSON-RPC 2.0 response (or batch array)"
                }
              }
            }
          },
          "500": {
            "description": "Internal error"
          }
        }
      },
      "get": {
        "operationId": "mcpGet",
        "summary": "Not supported (no SSE stream)",
        "responses": {
          "405": {
            "description": "Method not allowed",
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST, OPTIONS"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "mcpDelete",
        "summary": "Not supported (no sessions)",
        "responses": {
          "405": {
            "description": "Method not allowed",
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST, OPTIONS"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_input",
                  "too_large",
                  "rate_limited",
                  "daily_limit",
                  "method_not_allowed",
                  "not_found",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Issue": {
        "type": "object",
        "properties": {
          "level": {
            "type": "string",
            "enum": [
              "error",
              "warning",
              "info"
            ]
          },
          "code": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "suggestion": {
            "type": "string"
          }
        },
        "required": [
          "level",
          "code",
          "path",
          "message"
        ]
      },
      "Report": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "summary": {
            "type": "object",
            "properties": {
              "errors": {
                "type": "integer"
              },
              "warnings": {
                "type": "integer"
              },
              "infos": {
                "type": "integer"
              },
              "pages": {
                "type": "integer"
              },
              "alternates": {
                "type": "integer"
              },
              "codes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "source": {
                "type": "string",
                "enum": [
                  "json",
                  "html",
                  "sitemap"
                ]
              }
            }
          },
          "issues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Issue"
            }
          },
          "truncated": {
            "type": "boolean"
          },
          "meta": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              },
              "fetchesUrls": {
                "type": "boolean",
                "const": false
              }
            }
          }
        },
        "required": [
          "valid",
          "summary",
          "issues",
          "meta"
        ]
      }
    }
  }
}