{
  "openapi": "3.1.0",
  "info": {
    "title": "Cravatar Unified Read-Plane API",
    "version": "0.5.0",
    "description": "High-performance, zero-PII read-plane API for Cravatar avatars, public profiles (Gravatar REST API v3 compatible), and site favicons."
  },
  "servers": [
    {
      "url": "https://cravatar.com",
      "description": "Cravatar Production"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Cravatar Developer or Partner API key (crav_live_...)."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Cravatar API key passed as Authorization: Bearer crav_live_..."
      }
    },
    "schemas": {
      "AvatarMeta": {
        "type": "object",
        "required": ["hash", "hash_type", "avatar_from", "has_owned_avatar", "org_verified", "org_slug", "supported_formats", "canonical_url"],
        "properties": {
          "hash": { "type": "string", "description": "Normalized lowercase SHA-256 (64 hex) or MD5 (32 hex) hash." },
          "hash_type": { "type": "string", "enum": ["sha256", "md5"] },
          "avatar_from": { "type": "string", "enum": ["cravatar", "org", "public", "disposable", "qq", "gravatar", "default", "ban"] },
          "has_owned_avatar": { "type": "boolean" },
          "org_verified": { "type": "boolean" },
          "org_slug": { "type": "string" },
          "supported_formats": { "type": "array", "items": { "type": "string" } },
          "canonical_url": { "type": "string", "format": "uri" }
        }
      },
      "PublicProfile": {
        "type": "object",
        "required": ["hash", "profile_url", "avatar_url", "display_name", "description", "verified_org"],
        "properties": {
          "hash": { "type": "string" },
          "profile_url": { "type": "string" },
          "avatar_url": { "type": "string", "format": "uri" },
          "display_name": { "type": "string" },
          "description": { "type": "string" },
          "verified_org": { "type": "string" }
        }
      },
      "FaviconMeta": {
        "type": "object",
        "required": ["status", "mime", "updated_at", "icon_url"],
        "properties": {
          "status": { "type": "string", "enum": ["ready", "queued", "fallback", "banned"] },
          "mime": { "type": "string" },
          "updated_at": { "type": ["string", "null"], "format": "date-time" },
          "icon_url": { "type": "string", "format": "uri" }
        }
      }
    }
  },
  "paths": {
    "/api/v1/health": {
      "get": {
        "summary": "Read-plane health and capabilities",
        "responses": {
          "200": { "description": "Service health status, snapshot freshness, and supported image formats." }
        }
      }
    },
    "/api/v1/avatar/meta/{hash}": {
      "get": {
        "summary": "Get zero-PII metadata for a single SHA-256 or MD5 avatar hash",
        "parameters": [
          { "name": "hash", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Avatar metadata",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AvatarMeta" } } }
          },
          "400": { "description": "Invalid hash (must be 32-char MD5 or 64-char SHA-256 hex)" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    },
    "/api/v1/avatar/batch-meta": {
      "post": {
        "summary": "Batch avatar metadata lookup (up to 50 hashes)",
        "security": [{ "ApiKeyHeader": [] }, { "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["hashes"],
                "properties": {
                  "hashes": { "type": "array", "minItems": 1, "maxItems": 50, "items": { "type": "string" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Batch metadata array" },
          "400": { "description": "Invalid payload or >50 hashes" },
          "401": { "description": "Valid API key required" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    },
    "/api/v1/profiles/{hash}": {
      "get": {
        "summary": "Get Gravatar REST API v3 compatible public user profile",
        "parameters": [
          { "name": "hash", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Opted-in public profile",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PublicProfile" } } }
          },
          "400": { "description": "Invalid hash" },
          "404": { "description": "Profile not found or not public" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    },
    "/api/v1/favicon/meta": {
      "get": {
        "summary": "Get site favicon status and metadata",
        "security": [{ "ApiKeyHeader": [] }, { "BearerAuth": [] }],
        "parameters": [
          { "name": "url", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Favicon metadata",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FaviconMeta" } } }
          },
          "400": { "description": "Invalid URL" },
          "401": { "description": "Valid API key required" },
          "403": { "description": "Private or disallowed host" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "summary": "OpenAPI 3.1 specification",
        "responses": {
          "200": { "description": "OpenAPI 3.1 JSON document" }
        }
      }
    }
  }
}
