{
  "openapi": "3.0.0",
  "info": {
    "title": "Indexly API",
    "description": "API for customer integrations with Indexly AI Search Visibility and brand analytics.",
    "version": "1.0.0",
    "contact": {
      "name": "Indexly Support",
      "email": "hello@indexly.ai",
      "url": "https://indexly.ai"
    }
  },
  "servers": [
    {
      "url": "https://app.indexly.ai",
      "description": "Production"
    },
    {
      "url": "http://localhost:3000",
      "description": "Development"
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "API key validation"
    },
    {
      "name": "Visibility",
      "description": "Brand visibility time series"
    },
    {
      "name": "Brands",
      "description": "Competitor and brand analysis"
    },
    {
      "name": "Brand Sentiments",
      "description": "Brand sentiments and tracked prompts"
    },
    {
      "name": "Content",
      "description": "Generated articles and content management"
    }
  ],
  "paths": {
    "/api/v1/validate": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "Validate API Key",
        "description": "Validate an API key and get associated organization details. Use this to verify your key before making other requests.",
        "operationId": "validateApiKey",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Valid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "valid",
                    "organization",
                    "apiKey"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "description": "Whether the API key is valid"
                    },
                    "keyType": {
                      "type": "string",
                      "description": "Type of the API key"
                    },
                    "organization": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Organization ID"
                        },
                        "name": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "key": {
                              "type": "string"
                            },
                            "organizationId": {
                              "type": "string"
                            },
                            "userId": {
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "lastUsedAt": {
                              "type": "string",
                              "format": "date-time",
                              "nullable": true
                            },
                            "organization": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "apiKey": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "key": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "lastUsedAt": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/brand-analysis/{siteId}": {
      "get": {
        "tags": [
          "Visibility"
        ],
        "summary": "Brand Analysis Overview",
        "description": "Get detailed brand analysis including overall sentiment, competitors, aggregated metrics, and detailed prompt analysis across various AI models.",
        "operationId": "getBrandAnalysis",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          }
        ],
        "responses": {
          "200": {
            "description": "Brand Analysis Details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "siteId": {
                      "type": "string"
                    },
                    "website": {
                      "type": "string"
                    },
                    "companyName": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "brand": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "website": {
                          "type": "string",
                          "nullable": true
                        },
                        "isUserBrand": {
                          "type": "boolean"
                        }
                      }
                    },
                    "competitors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "totalPrompts": {
                      "type": "integer",
                      "nullable": true
                    },
                    "presentCount": {
                      "type": "integer",
                      "nullable": true
                    },
                    "averageRank": {
                      "type": "number",
                      "nullable": true
                    },
                    "totalVolume": {
                      "type": "integer",
                      "nullable": true
                    },
                    "overallSentiment": {
                      "type": "object",
                      "properties": {
                        "score": {
                          "type": "integer",
                          "nullable": true
                        },
                        "summary": {
                          "type": "string"
                        },
                        "strengths": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "weaknesses": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "analyzedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "openaiPrompts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PromptAnalysis"
                      }
                    },
                    "claudePrompts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PromptAnalysis"
                      }
                    },
                    "googlePrompts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PromptAnalysis"
                      }
                    },
                    "perplexityPrompts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PromptAnalysis"
                      }
                    },
                    "grokPrompts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PromptAnalysis"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid site ID",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/citations/{siteId}": {
      "get": {
        "tags": [
          "Visibility"
        ],
        "summary": "Citation Analysis",
        "description": "Get detailed citation analysis across AI models including references to your domain, URLs, and competitor citations.",
        "operationId": "citationAnalysis",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 1
            },
            "description": "Page number for pagination"
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 20,
              "maximum": 100
            },
            "description": "Number of results per page"
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "my",
                "competitors"
              ],
              "default": "my"
            },
            "description": "Scope of citations to analyze (your brand vs competitors)"
          },
          {
            "name": "viewType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "url",
                "domain"
              ],
              "default": "url"
            },
            "description": "Group citations by specific URL or root domain"
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "gap"
              ],
              "default": "all"
            },
            "description": "Filter type (show 'all' citations, or just the 'gap' of competitor citations you lack)"
          },
          {
            "name": "aiModelName",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "OPENAI",
                "GOOGLE",
                "PERPLEXITY",
                "GROK",
                "AIOVERVIEW"
              ]
            },
            "description": "Filter citations by a specific AI model"
          }
        ],
        "responses": {
          "200": {
            "description": "Detailed citation analysis data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "citations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "totalCitations": {
                            "type": "integer"
                          },
                          "position": {
                            "type": "number",
                            "nullable": true
                          },
                          "modelBreakdown": {
                            "type": "object",
                            "properties": {
                              "OPENAI": {
                                "type": "integer"
                              },
                              "GOOGLE": {
                                "type": "integer"
                              },
                              "PERPLEXITY": {
                                "type": "integer"
                              },
                              "AIOVERVIEW": {
                                "type": "integer"
                              },
                              "GROK": {
                                "type": "integer"
                              },
                              "CLAUDE": {
                                "type": "integer"
                              }
                            }
                          },
                          "statusCode": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "integer"
                        },
                        "pageSize": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "totalPages": {
                          "type": "integer"
                        }
                      }
                    },
                    "lastCalculatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    },
                    "isCalculating": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/ai-readiness/{siteId}/latest": {
      "get": {
        "tags": [
          "AI Audit"
        ],
        "summary": "AI Readiness Audit",
        "description": "Get the latest AI Readiness Audit report for a specific site.",
        "operationId": "getLatestAIAudit",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          }
        ],
        "responses": {
          "200": {
            "description": "Latest AI Readiness Audit data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "audit": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "success": {
                          "type": "boolean"
                        },
                        "url": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "score": {
                          "type": "object",
                          "properties": {
                            "overall": {
                              "type": "integer"
                            },
                            "details": {
                              "type": "object",
                              "additionalProperties": true
                            }
                          }
                        },
                        "recommendations": {
                          "type": "object",
                          "additionalProperties": true
                        },
                        "auditDetails": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/brand-analysis/{siteId}/history": {
      "get": {
        "tags": [
          "Visibility"
        ],
        "summary": "Visibility time series",
        "description": "Get brand visibility history for a site. Returns time-series data and optional summary for your brand.",
        "operationId": "visibilityHistory",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 7,
              "maximum": 30,
              "minimum": 1
            },
            "description": "Number of days of history (default 7, capped at 30)"
          },
          {
            "name": "userBrandOnly",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "If true, response includes summary for your brand when available"
          }
        ],
        "responses": {
          "200": {
            "description": "Visibility time series",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "description": "Each object has date (string) plus dynamic keys per brand name with visibility 0-100",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "brands": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "website": {
                            "type": "string"
                          },
                          "visibility": {
                            "type": "number"
                          },
                          "position": {
                            "type": "number",
                            "nullable": true
                          },
                          "sentiment": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "summary": {
                      "type": "object",
                      "nullable": true,
                      "description": "Present when userBrandOnly=true and user brand exists",
                      "properties": {
                        "currentVisibility": {
                          "type": "number",
                          "nullable": true
                        },
                        "dayChange": {
                          "type": "number",
                          "nullable": true
                        },
                        "weekChange": {
                          "type": "number",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid site ID",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/brand-analysis/{siteId}/brands": {
      "get": {
        "tags": [
          "Brands"
        ],
        "summary": "Competitor analysis",
        "description": "Get list of brands (including your brand and competitors) with visibility, mentions, and position for the given site.",
        "operationId": "competitorAnalysis",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          }
        ],
        "responses": {
          "200": {
            "description": "List of brands",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "brands": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "website": {
                            "type": "string",
                            "nullable": true
                          },
                          "isUser": {
                            "type": "boolean"
                          },
                          "visibility": {
                            "type": "number"
                          },
                          "mentions": {
                            "type": "number"
                          },
                          "position": {
                            "type": "integer",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/brand-sentiments/{siteId}/tracked-prompts": {
      "get": {
        "tags": [
          "Brand Sentiments"
        ],
        "summary": "Tracked Prompts",
        "description": "Get paginated list of tracked prompts and their AI-generated responses with sentiment analysis.",
        "operationId": "trackedPromptsSentiments",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 1
            },
            "description": "Page number for pagination"
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 10
            },
            "description": "Number of items per page"
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filter by AI model"
          },
          {
            "name": "sentiment",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filter by sentiment"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated tracked prompts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "responses": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "prompt": {
                            "type": "string"
                          },
                          "promptId": {
                            "type": "string"
                          },
                          "sentiment": {
                            "type": "string"
                          },
                          "aiModelName": {
                            "type": "string"
                          },
                          "response": {
                            "type": "string"
                          },
                          "analyzedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "integer"
                        },
                        "pageSize": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "totalPages": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/brand-sentiments/{siteId}/analysis": {
      "get": {
        "tags": [
          "Brand Sentiments"
        ],
        "summary": "Brand Sentiment Analysis",
        "description": "Get the overall brand sentiment score, summary, strengths, and weaknesses for your brand.",
        "operationId": "brandSentimentAnalysis",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          }
        ],
        "responses": {
          "200": {
            "description": "Brand Sentiment Analysis",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sentimentScore": {
                      "type": "number",
                      "nullable": true
                    },
                    "sentimentSummary": {
                      "type": "string"
                    },
                    "strengths": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "weaknesses": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "analyzedAt": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/brand-sentiments/{siteId}/brands": {
      "get": {
        "tags": [
          "Brand Sentiments"
        ],
        "summary": "Brands Net Sentiment",
        "description": "Get sentiment analysis scores comparing your brand against top competitors for a given site.",
        "operationId": "brandsNetSentiment",
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Site ID (must belong to your organization)"
          }
        ],
        "responses": {
          "200": {
            "description": "List of brands net sentiment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "brands": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "website": {
                            "type": "string"
                          },
                          "netSentiment": {
                            "type": "number"
                          },
                          "ranking": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Site not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Upgrade required to access feature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/content": {
      "get": {
        "tags": [
          "Content"
        ],
        "summary": "Get Content",
        "description": "Retrieve generated articles and content drafts. Supports fetching a specific article by ID or listing article generations with filtering options.",
        "operationId": "getContent",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Specific article generation ID. When provided, returns a single article generation."
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filter article generations by site ID."
          },
          {
            "name": "isAutoPilot",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Filter article generations created through AutoPilot."
          },
          {
            "name": "includeUnassigned",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include content items that are not assigned to any site."
          },
          {
            "name": "light",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Return lightweight article objects without full content, excerpt, and hero image fields."
          }
        ],
        "responses": {
          "200": {
            "description": "Content retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/ArticleGeneration"
                        },
                        {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ArticleGenerationListItem"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Article generation not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Article generation not found"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Too Many Requests"
                    },
                    "message": {
                      "type": "string",
                      "example": "API rate limit exceeded. Try after 1 minute."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API key from Indexly dashboard (Settings > API Keys)"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "PromptAnalysis": {
        "type": "object",
        "properties": {
          "prompt": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "present": {
            "type": "boolean"
          },
          "rank": {
            "type": "integer",
            "nullable": true
          },
          "volume": {
            "type": "integer",
            "nullable": true
          },
          "details": {
            "type": "object",
            "properties": {
              "competitors": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "fullResponse": {
                "type": "string"
              },
              "sentiment": {
                "type": "string",
                "enum": [
                  "positive",
                  "neutral",
                  "negative"
                ]
              },
              "marketPosition": {
                "type": "string"
              },
              "competitorPerformance": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "prevalence": {
                      "type": "number"
                    },
                    "avgRank": {
                      "type": "number",
                      "nullable": true
                    }
                  }
                }
              },
              "prevalence": {
                "type": "object",
                "properties": {
                  "userBrand": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "mentions": {
            "type": "integer",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "ArticleGeneration": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "topic": {
            "type": "string",
            "nullable": true
          },
          "selectedTitle": {
            "type": "string",
            "nullable": true
          },
          "articleFormat": {
            "type": "string",
            "nullable": true
          },
          "articleType": {
            "type": "string",
            "nullable": true
          },
          "primaryKeyword": {
            "type": "string",
            "nullable": true
          },
          "secondaryKeyword": {
            "type": "string",
            "nullable": true
          },
          "selectedKeywords": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "currentStep": {
            "type": "string",
            "nullable": true
          },
          "isCompleted": {
            "type": "boolean"
          },
          "isAutoPilot": {
            "type": "boolean"
          },
          "siteId": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "language": {
            "type": "string",
            "nullable": true
          },
          "tone": {
            "type": "string",
            "nullable": true
          },
          "objective": {
            "type": "string",
            "nullable": true
          },
          "brandNarrative": {
            "type": "string",
            "nullable": true
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "fullArticle": {
            "type": "string",
            "nullable": true
          },
          "outline": {
            "type": "string",
            "nullable": true
          },
          "excerpt": {
            "type": "string",
            "nullable": true
          },
          "heroImage": {
            "type": "string",
            "nullable": true
          },
          "isPublishedToCMS": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "contentPlan": {
            "$ref": "#/components/schemas/ContentPlan"
          }
        }
      },
      "ArticleGenerationListItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ArticleGeneration"
          }
        ]
      },
      "ContentPlan": {
        "type": "object",
        "properties": {
          "topic": {
            "type": "string",
            "nullable": true
          },
          "primaryKeyword": {
            "type": "string",
            "nullable": true
          },
          "secondaryKeyword": {
            "type": "string",
            "nullable": true
          },
          "tone": {
            "type": "string",
            "nullable": true
          },
          "objective": {
            "type": "string",
            "nullable": true
          },
          "audience": {
            "type": "string",
            "nullable": true
          },
          "outline": {
            "type": "string",
            "nullable": true
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ]
}