{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/viralnote-app/json-schema/viralnote-app-ai-visibility-status-schema.json",
  "title": "AiVisibilityStatus",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/viralnote-app-openapi.json#/components/schemas/AiVisibilityStatus",
  "type": "object",
  "properties": {
    "brandId": {
      "type": "string"
    },
    "tier": {
      "type": "string",
      "enum": [
        "none",
        "snapshot",
        "included",
        "addon",
        "agency_addon"
      ]
    },
    "limits": {
      "type": "object",
      "properties": {
        "prompts": {
          "type": "integer"
        },
        "brands": {
          "type": "integer"
        },
        "cadenceDays": {
          "type": [
            "integer",
            "null"
          ]
        },
        "maxSamples": {
          "type": "integer"
        }
      }
    },
    "recurring": {
      "type": "boolean",
      "description": "Whether this plan checks on a schedule"
    },
    "freeScoreAvailable": {
      "type": "boolean"
    },
    "brandReady": {
      "type": "boolean",
      "description": "A brand name is saved in Brand Kit. When false, add the brand before requesting setup suggestions."
    },
    "runNow": {
      "type": "object",
      "properties": {
        "allowed": {
          "type": "boolean"
        },
        "kind": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        },
        "availableAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "config": {
      "type": [
        "object",
        "null"
      ],
      "description": "What's tracked; null until set up"
    },
    "latestSummary": {
      "allOf": [
        {
          "$ref": "#/$defs/AiVisibilitySummary"
        }
      ],
      "nullable": true
    },
    "history": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AiVisibilitySummary"
      }
    },
    "trend": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "latest": {
          "type": "number"
        },
        "rollingAverage": {
          "type": "number"
        },
        "delta": {
          "type": [
            "number",
            "null"
          ]
        },
        "threshold": {
          "type": "number"
        },
        "significant": {
          "type": "boolean"
        },
        "series": {
          "type": "integer"
        }
      }
    },
    "activeRun": {
      "allOf": [
        {
          "$ref": "#/$defs/AiVisibilityRun"
        }
      ],
      "nullable": true
    },
    "nextRunAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "websiteUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "The Brand Kit website the site audit checks"
    },
    "audit": {
      "allOf": [
        {
          "$ref": "#/$defs/AiVisibilitySiteAudit"
        }
      ],
      "nullable": true
    },
    "gaps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AiVisibilityGap"
      }
    },
    "fixesCited": {
      "type": "integer",
      "description": "Fixes AI cited in the latest check"
    },
    "digestEnabled": {
      "type": "boolean",
      "description": "Whether the owner gets an email after each scheduled check"
    }
  },
  "$defs": {
    "AiVisibilityAuditCheck": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "pass",
            "warn",
            "fail",
            "info"
          ]
        },
        "title": {
          "type": "string"
        },
        "detail": {
          "type": "string"
        },
        "fix": {
          "type": "string",
          "description": "What to change"
        },
        "snippet": {
          "type": "string",
          "description": "Copy-paste text for the fix, such as a robots.txt group or a JSON-LD block"
        }
      }
    },
    "AiVisibilityGap": {
      "type": "object",
      "description": "A tracked question where AI answers name others instead of the brand",
      "properties": {
        "promptId": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "cluster": {
          "type": "string",
          "enum": [
            "category",
            "problem",
            "comparison"
          ]
        },
        "brandRate": {
          "type": "number",
          "description": "Share of this question's answers naming the brand"
        },
        "namedInstead": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "count": {
                "type": "integer"
              }
            }
          }
        },
        "engines": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "openai",
              "gemini",
              "claude",
              "google"
            ]
          }
        },
        "severity": {
          "type": "number"
        }
      }
    },
    "AiVisibilityMetrics": {
      "type": "object",
      "description": "Headline AI Visibility metrics. Prompts that name the brand are left out, since those answers always mention it.",
      "properties": {
        "answers": {
          "type": "integer"
        },
        "mentionRate": {
          "type": "number",
          "description": "Share of answers that mention the brand (0–1)"
        },
        "shareOfVoice": {
          "type": [
            "number",
            "null"
          ],
          "description": "Brand mentions ÷ brand plus competitor mentions"
        },
        "avgPosition": {
          "type": [
            "number",
            "null"
          ],
          "description": "Mean rank among recommended products, when recommended"
        },
        "recommendedRate": {
          "type": "number",
          "description": "Share of answers that recommend the brand"
        },
        "citationRate": {
          "type": "number",
          "description": "Share of answers citing one of the brand's domains"
        },
        "score": {
          "type": "number",
          "description": "0–100: 50 × mentionRate + 20 × shareOfVoice + 15 × position score + 15 × citationRate"
        }
      }
    },
    "AiVisibilityRun": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "running",
            "complete",
            "partial",
            "failed"
          ]
        },
        "tier": {
          "type": "string",
          "enum": [
            "snapshot",
            "included",
            "addon",
            "agency_addon"
          ]
        },
        "promptSetVersion": {
          "type": "integer"
        },
        "taskCount": {
          "type": "integer"
        },
        "completed": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        },
        "costUsd": {
          "type": "number"
        },
        "startedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "summary": {
          "allOf": [
            {
              "$ref": "#/$defs/AiVisibilitySummary"
            }
          ],
          "nullable": true
        }
      }
    },
    "AiVisibilitySiteAudit": {
      "type": "object",
      "description": "How AI crawlers see the brand's website. Refreshed when each check starts, or with runAiVisibilityAudit.",
      "properties": {
        "url": {
          "type": "string",
          "description": "The homepage after redirects"
        },
        "checkedAt": {
          "type": "string",
          "format": "date-time"
        },
        "checks": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AiVisibilityAuditCheck"
          }
        },
        "robots": {
          "type": "object",
          "properties": {
            "found": {
              "type": "boolean"
            },
            "bots": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "operator": {
                    "type": "string"
                  },
                  "purpose": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "answers",
                      "training"
                    ]
                  },
                  "allowed": {
                    "type": "boolean"
                  }
                }
              }
            },
            "sitemaps": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "AiVisibilitySummary": {
      "allOf": [
        {
          "$ref": "#/$defs/AiVisibilityMetrics"
        },
        {
          "type": "object",
          "properties": {
            "runId": {
              "type": "string"
            },
            "promptSetVersion": {
              "type": "integer"
            },
            "scoreComplete": {
              "type": "boolean",
              "description": "False when answer coverage or recommendation analysis is incomplete. Do not present the numeric score as a final comparison."
            },
            "measurementVersion": {
              "type": "integer",
              "description": "Analysis-method version; 0 means a resumed check contains mixed methods. Trends compare like methods."
            },
            "extractionFailed": {
              "type": "integer",
              "description": "Successful provider answers whose recommendation analysis did not finish"
            },
            "scoredCoverage": {
              "type": "object",
              "description": "Coverage of the answers the score is built from (questions that do not name the brand). Absent on checks before November 2026.",
              "properties": {
                "analyzed": {
                  "type": "integer",
                  "description": "Answers returned and fully analyzed"
                },
                "total": {
                  "type": "integer",
                  "description": "Answers the check asked for"
                },
                "enginesMissing": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Engines with no analyzed answer"
                }
              }
            },
            "completedAtMs": {
              "type": "integer"
            },
            "byEngine": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/$defs/AiVisibilityMetrics"
              }
            },
            "byCluster": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/$defs/AiVisibilityMetrics"
              }
            },
            "byPrompt": {
              "type": "object",
              "description": "promptId → engine → share of answers mentioning the brand",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {
                  "type": "number"
                }
              }
            },
            "namedInsteadByPrompt": {
              "type": "object",
              "description": "promptId → engine → who those answers named most besides the brand (tracked competitors and other recommended products), most named first, at most 2. Questions that name the brand are left out. Absent on checks before November 2026.",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            },
            "competitors": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "mentionRate": {
                    "type": "number"
                  },
                  "shareOfVoice": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                }
              }
            },
            "topCitedDomains": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string"
                  },
                  "count": {
                    "type": "integer"
                  },
                  "owner": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            },
            "sentiment": {
              "type": "object",
              "properties": {
                "positive": {
                  "type": "integer"
                },
                "neutral": {
                  "type": "integer"
                },
                "negative": {
                  "type": "integer"
                }
              }
            },
            "failed": {
              "type": "integer"
            },
            "costUsd": {
              "type": "number"
            }
          }
        }
      ]
    }
  }
}