{
  "openapi": "3.1.0",
  "info": {
    "title": "AthenaHQ API",
    "description": "AthenaHQ API provides programmatic access to manage your websites and prompts for AI-powered content optimization.",
    "version": "1.0.0",
    "contact": {
      "email": "support@athenahq.ai"
    }
  },
  "servers": [
    {
      "url": "https://api.athenahq.ai",
      "description": "Production server"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Basics",
      "description": "Core API operations for managing websites and prompts"
    },
    {
      "name": "Metrics",
      "description": "Metrics and analytics endpoints for tracking AI visibility"
    },
    {
      "name": "Billing",
      "description": "Billing and credits endpoints for managing usage"
    },
    {
      "name": "Team Management",
      "description": "Endpoints for managing team members and invitations"
    },
    {
      "name": "Groups",
      "description": "Endpoints for managing groups of websites"
    },
    {
      "name": "Content",
      "description": "Endpoints for accessing Content Hub data \u2014 tabs, tracked URLs, and per-URL prompt breakdowns."
    },
    {
      "name": "Pitch Workspace",
      "description": "Endpoints for accessing pitch workspace reports \u2014 org-scoped pitch runs with competitors, prompts, attributes, and aggregate metrics."
    },
    {
      "name": "Knowledge Base",
      "description": "Endpoints for reading the brand Knowledge Base \u2014 approved brand facts and the pillars that organize them."
    }
  ],
  "paths": {
    "/api/v1/sources/tiktok-creators": {
      "post": {
        "operationId": "sources.tiktokCreators",
        "summary": "List TikTok Creators",
        "description": "List TikTok handles cited in AI answers, ordered by citations with unattributed URLs last. Includes profiles, videos and photos across tiktok.com, www, m, vm and vt hosts. Handles come from cited URLs, not verified account identities; short links are not resolved. Citation shares and totals cover all filtered TikTok citations, including unattributed URLs, independent of pagination. Use get_tiktok_pages with channel_key to drill down. No scraping or live TikTok requests. Dates are inclusive UTC days. Results are cached for up to five minutes. Citation counts measure Athena-tracked AI answers, not TikTok views, followers or engagement. Handles are lowercase and do not reconcile account renames or verify ownership. Pagination is zero-based with at most 100 rows per page. The creators pagination total includes an unattributed group when present; totals.channels excludes it. Page URL strings preserve the Sources grouping key and may omit the scheme. Tracking-only query variants and text fragments are grouped as on Sources.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "creators": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "channel_key": {
                            "type": "string",
                            "description": "URL-derived handle group key; use with get_tiktok_pages. The unattributed group has key unattributed."
                          },
                          "handle": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "url": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "citations": {
                            "type": "number"
                          },
                          "share_percent": {
                            "type": "number"
                          },
                          "page_count": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "channel_key",
                          "handle",
                          "url",
                          "citations",
                          "share_percent",
                          "page_count"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page_num": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "page_size": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "page_num",
                        "page_size",
                        "total"
                      ],
                      "additionalProperties": false
                    },
                    "totals": {
                      "type": "object",
                      "properties": {
                        "citations": {
                          "type": "number"
                        },
                        "channels": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Attributed handles, excluding the unattributed group."
                        },
                        "unattributed_citations": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "citations",
                        "channels",
                        "unattributed_citations"
                      ],
                      "additionalProperties": false
                    },
                    "notice": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "creators",
                    "pagination",
                    "totals"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Bad Request \u2014 validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "filters": {
                    "type": "object",
                    "properties": {
                      "start_date": {
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
                        "description": "First day, YYYY-MM-DD, inclusive (UTC)."
                      },
                      "schedule_id": {
                        "description": "One schedule: \"default\" or a custom/archived schedule UUID. Omit for Default, which includes all pre-cutover history and ad hoc runs. The retired \"manual\" token is accepted as an alias of \"default\". Schedules cannot be combined.",
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "default",
                              "manual"
                            ]
                          },
                          {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        ]
                      },
                      "end_date": {
                        "description": "Last day, YYYY-MM-DD, inclusive (UTC). Defaults to today.",
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                      },
                      "models": {
                        "description": "AI models to include, as an array even for one model \u2014 e.g. [\"chatgpt\", \"perplexity\"]. Omit to include all models.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "chatgpt",
                            "perplexity",
                            "gemini",
                            "google_ai_overview",
                            "copilot",
                            "claude",
                            "ai_mode",
                            "grok",
                            "deepseek",
                            "meta_ai",
                            "mistral"
                          ]
                        }
                      },
                      "prompt_ids": {
                        "description": "Prompt UUIDs to filter to, as an array even for one id. Omit for all prompts.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "location_ids": {
                        "description": "Location UUIDs to filter to, as an array even for one id. The literal string \"no-location\" selects responses that ran without a location. Omit for all locations.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            {
                              "type": "string",
                              "const": "no-location"
                            }
                          ]
                        }
                      },
                      "persona_ids": {
                        "description": "Persona UUIDs to filter to, as an array even for one id. Omit for all personas.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "target_identifiers": {
                        "description": "Target identifier strings to filter to, as an array even for one value. The literal string \"no-identifier\" selects responses with no target identifier. Omit for all.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "string",
                              "const": "no-identifier"
                            }
                          ]
                        }
                      },
                      "variation_filter": {
                        "description": "Which prompt rows to include, as an array: \"prompt\" for base prompts, \"variation\" for generated variations, or both. Omit for both.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "variation",
                            "prompt"
                          ]
                        }
                      },
                      "prompt_tags": {
                        "description": "Prompt tag UUIDs from get_prompt_tags.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "prompt_tags_operator": {
                        "description": "How prompt_tags combine: \"is_any_of\" matches prompts with any listed tag, \"has_all_of\" only prompts carrying every listed tag.",
                        "type": "string",
                        "enum": [
                          "is_any_of",
                          "has_all_of"
                        ]
                      },
                      "prompt_status": {
                        "description": "Filter prompts by tracking status: \"active\" or \"paused\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "active",
                          "paused"
                        ]
                      },
                      "prompt_type": {
                        "description": "Filter prompts by type: \"branded\" (mentions the brand) or \"non_branded\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "branded",
                          "non_branded"
                        ]
                      }
                    },
                    "required": [
                      "start_date"
                    ],
                    "additionalProperties": false
                  },
                  "page_num": {
                    "default": 0,
                    "description": "Zero-based page number.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "page_size": {
                    "default": 30,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "required": [
                  "website_id",
                  "filters"
                ]
              },
              "example": {
                "website_id": "123e4567-e89b-42d3-a456-426614174000",
                "filters": {
                  "start_date": "2026-10-01",
                  "end_date": "2026-10-31"
                },
                "page_num": 0,
                "page_size": 30
              }
            }
          }
        },
        "tags": [
          "Sources"
        ],
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/api/v1/sources/tiktok-pages": {
      "post": {
        "operationId": "sources.tiktokPages",
        "summary": "List TikTok Pages",
        "description": "List TikTok URLs cited in AI answers, ordered by citations. Includes profile, video, photo and unattributed URLs. Filter by channel_key from get_tiktok_creators. Each page's share_percent and totals use all filtered TikTok citations, including unattributed URLs, even when drilling into one channel or paginating. These are AI-answer citation counts, not TikTok views or engagement. No scraping or live TikTok requests. Dates are inclusive UTC days. Results are cached for up to five minutes. Citation counts measure Athena-tracked AI answers, not TikTok views, followers or engagement. Handles are lowercase and do not reconcile account renames or verify ownership. Pagination is zero-based with at most 100 rows per page. The creators pagination total includes an unattributed group when present; totals.channels excludes it. Page URL strings preserve the Sources grouping key and may omit the scheme. Tracking-only query variants and text fragments are grouped as on Sources.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "channel": {
                            "type": "object",
                            "properties": {
                              "channel_key": {
                                "type": "string",
                                "description": "URL-derived handle group key; use with get_tiktok_pages. The unattributed group has key unattributed."
                              },
                              "handle": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "url": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "channel_key",
                              "handle",
                              "url"
                            ],
                            "additionalProperties": false
                          },
                          "citations": {
                            "type": "number"
                          },
                          "share_percent": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "url",
                          "channel",
                          "citations",
                          "share_percent"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page_num": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "page_size": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "page_num",
                        "page_size",
                        "total"
                      ],
                      "additionalProperties": false
                    },
                    "totals": {
                      "type": "object",
                      "properties": {
                        "citations": {
                          "type": "number"
                        },
                        "channels": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Attributed handles, excluding the unattributed group."
                        },
                        "unattributed_citations": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "citations",
                        "channels",
                        "unattributed_citations"
                      ],
                      "additionalProperties": false
                    },
                    "notice": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "pages",
                    "pagination",
                    "totals"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Bad Request \u2014 validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "filters": {
                    "type": "object",
                    "properties": {
                      "start_date": {
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
                        "description": "First day, YYYY-MM-DD, inclusive (UTC)."
                      },
                      "schedule_id": {
                        "description": "One schedule: \"default\" or a custom/archived schedule UUID. Omit for Default, which includes all pre-cutover history and ad hoc runs. The retired \"manual\" token is accepted as an alias of \"default\". Schedules cannot be combined.",
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "default",
                              "manual"
                            ]
                          },
                          {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        ]
                      },
                      "end_date": {
                        "description": "Last day, YYYY-MM-DD, inclusive (UTC). Defaults to today.",
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                      },
                      "models": {
                        "description": "AI models to include, as an array even for one model \u2014 e.g. [\"chatgpt\", \"perplexity\"]. Omit to include all models.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "chatgpt",
                            "perplexity",
                            "gemini",
                            "google_ai_overview",
                            "copilot",
                            "claude",
                            "ai_mode",
                            "grok",
                            "deepseek",
                            "meta_ai",
                            "mistral"
                          ]
                        }
                      },
                      "prompt_ids": {
                        "description": "Prompt UUIDs to filter to, as an array even for one id. Omit for all prompts.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "location_ids": {
                        "description": "Location UUIDs to filter to, as an array even for one id. The literal string \"no-location\" selects responses that ran without a location. Omit for all locations.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            {
                              "type": "string",
                              "const": "no-location"
                            }
                          ]
                        }
                      },
                      "persona_ids": {
                        "description": "Persona UUIDs to filter to, as an array even for one id. Omit for all personas.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "target_identifiers": {
                        "description": "Target identifier strings to filter to, as an array even for one value. The literal string \"no-identifier\" selects responses with no target identifier. Omit for all.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "string",
                              "const": "no-identifier"
                            }
                          ]
                        }
                      },
                      "variation_filter": {
                        "description": "Which prompt rows to include, as an array: \"prompt\" for base prompts, \"variation\" for generated variations, or both. Omit for both.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "variation",
                            "prompt"
                          ]
                        }
                      },
                      "prompt_tags": {
                        "description": "Prompt tag UUIDs from get_prompt_tags.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "prompt_tags_operator": {
                        "description": "How prompt_tags combine: \"is_any_of\" matches prompts with any listed tag, \"has_all_of\" only prompts carrying every listed tag.",
                        "type": "string",
                        "enum": [
                          "is_any_of",
                          "has_all_of"
                        ]
                      },
                      "prompt_status": {
                        "description": "Filter prompts by tracking status: \"active\" or \"paused\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "active",
                          "paused"
                        ]
                      },
                      "prompt_type": {
                        "description": "Filter prompts by type: \"branded\" (mentions the brand) or \"non_branded\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "branded",
                          "non_branded"
                        ]
                      }
                    },
                    "required": [
                      "start_date"
                    ],
                    "additionalProperties": false
                  },
                  "page_num": {
                    "default": 0,
                    "description": "Zero-based page number.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "page_size": {
                    "default": 30,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  },
                  "channel_key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "Group key from get_tiktok_creators, including unattributed; omit for all cited pages."
                  }
                },
                "required": [
                  "website_id",
                  "filters"
                ]
              },
              "example": {
                "website_id": "123e4567-e89b-42d3-a456-426614174000",
                "filters": {
                  "start_date": "2026-10-01",
                  "end_date": "2026-10-31"
                },
                "page_num": 0,
                "page_size": 30
              }
            }
          }
        },
        "tags": [
          "Sources"
        ],
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/api/v1/sources/youtube-creators": {
      "post": {
        "operationId": "sources.youtubeCreators",
        "summary": "List YouTube Creators",
        "description": "List YouTube channels cited in AI answers for a website, ordered by citations (unknown channel last). Includes channel citation shares, category and video-length breakdowns, and metadata availability. Totals and breakdowns cover the full filtered result, independent of pagination. Use get_youtube_videos with channel_key to list a creator's videos. Reads saved metadata; pending or missing details remain null. Dates are inclusive UTC days. Counts cover citations in Athena-tracked AI answers, not YouTube views or subscriber analytics. Metadata is read from Athena’s saved cache and may be unavailable. Channel share uses all YouTube citations, including non-video links; category and length shares use video citations. Video citation_percentage is the percentage of distinct filtered AI responses citing that video. first_seen is within the selected date range. The completed breakdown, including citation metrics and saved metadata, is cached for up to five minutes.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "creators": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "channel_key": {
                            "type": "string",
                            "description": "Stable group key; use as channel_key in get_youtube_videos."
                          },
                          "channel_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "handle": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "url": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "thumbnail_url": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "citations": {
                            "type": "number"
                          },
                          "share_percent": {
                            "type": "number"
                          },
                          "video_count": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "main_category_id": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_duration_seconds": {
                            "type": [
                              "number",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "channel_key",
                          "channel_id",
                          "name",
                          "handle",
                          "url",
                          "thumbnail_url",
                          "citations",
                          "share_percent",
                          "video_count",
                          "main_category_id",
                          "avg_duration_seconds"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page_num": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "page_size": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "page_num",
                        "page_size",
                        "total"
                      ],
                      "additionalProperties": false
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "category_id": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "citations": {
                            "type": "number"
                          },
                          "share_percent": {
                            "type": "number"
                          },
                          "videos": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "category_id",
                          "citations",
                          "share_percent",
                          "videos"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "length_buckets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "enum": [
                              "under-1",
                              "1-5",
                              "5-15",
                              "15-30",
                              "30-60",
                              "60-plus"
                            ]
                          },
                          "citations": {
                            "type": "number"
                          },
                          "share_percent": {
                            "type": "number"
                          },
                          "videos": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "id",
                          "citations",
                          "share_percent",
                          "videos"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "totals": {
                      "type": "object",
                      "properties": {
                        "citations": {
                          "type": "number"
                        },
                        "video_citations": {
                          "type": "number"
                        },
                        "non_video_citations": {
                          "type": "number"
                        },
                        "videos": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "channels": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "top_ten_channel_share_percent": {
                          "type": "number"
                        },
                        "median_duration_seconds": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "pending": {
                          "type": "object",
                          "properties": {
                            "videos": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "citations": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "videos",
                            "citations"
                          ],
                          "additionalProperties": false
                        },
                        "missing": {
                          "type": "object",
                          "properties": {
                            "videos": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "citations": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "videos",
                            "citations"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "citations",
                        "video_citations",
                        "non_video_citations",
                        "videos",
                        "channels",
                        "top_ten_channel_share_percent",
                        "median_duration_seconds",
                        "pending",
                        "missing"
                      ],
                      "additionalProperties": false
                    },
                    "notice": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "creators",
                    "pagination",
                    "categories",
                    "length_buckets",
                    "totals"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "filters": {
                    "type": "object",
                    "properties": {
                      "start_date": {
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
                        "description": "First day, YYYY-MM-DD, inclusive (UTC)."
                      },
                      "schedule_id": {
                        "description": "One schedule: \"default\" or a custom/archived schedule UUID. Omit for Default, which includes all pre-cutover history and ad hoc runs. The retired \"manual\" token is accepted as an alias of \"default\". Schedules cannot be combined.",
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "default",
                              "manual"
                            ]
                          },
                          {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        ]
                      },
                      "end_date": {
                        "description": "Last day, YYYY-MM-DD, inclusive (UTC). Defaults to today.",
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                      },
                      "models": {
                        "description": "AI models to include, as an array even for one model — e.g. [\"chatgpt\", \"perplexity\"]. Omit to include all models.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "chatgpt",
                            "perplexity",
                            "gemini",
                            "google_ai_overview",
                            "copilot",
                            "claude",
                            "ai_mode",
                            "grok",
                            "deepseek",
                            "meta_ai",
                            "mistral"
                          ]
                        }
                      },
                      "prompt_ids": {
                        "description": "Prompt UUIDs to filter to, as an array even for one id. Omit for all prompts.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "location_ids": {
                        "description": "Location UUIDs to filter to, as an array even for one id. The literal string \"no-location\" selects responses that ran without a location. Omit for all locations.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            {
                              "type": "string",
                              "const": "no-location"
                            }
                          ]
                        }
                      },
                      "persona_ids": {
                        "description": "Persona UUIDs to filter to, as an array even for one id. Omit for all personas.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "target_identifiers": {
                        "description": "Target identifier strings to filter to, as an array even for one value. The literal string \"no-identifier\" selects responses with no target identifier. Omit for all.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "string",
                              "const": "no-identifier"
                            }
                          ]
                        }
                      },
                      "variation_filter": {
                        "description": "Which prompt rows to include, as an array: \"prompt\" for base prompts, \"variation\" for generated variations, or both. Omit for both.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "variation",
                            "prompt"
                          ]
                        }
                      },
                      "prompt_tags": {
                        "description": "Prompt tag UUIDs from get_prompt_tags.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "prompt_tags_operator": {
                        "description": "How prompt_tags combine: \"is_any_of\" matches prompts with any listed tag, \"has_all_of\" only prompts carrying every listed tag.",
                        "type": "string",
                        "enum": [
                          "is_any_of",
                          "has_all_of"
                        ]
                      },
                      "prompt_status": {
                        "description": "Filter prompts by tracking status: \"active\" or \"paused\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "active",
                          "paused"
                        ]
                      },
                      "prompt_type": {
                        "description": "Filter prompts by type: \"branded\" (mentions the brand) or \"non_branded\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "branded",
                          "non_branded"
                        ]
                      }
                    },
                    "required": [
                      "start_date"
                    ],
                    "additionalProperties": false
                  },
                  "page_num": {
                    "default": 0,
                    "description": "Zero-based page number.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "page_size": {
                    "default": 30,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "required": [
                  "website_id",
                  "filters"
                ]
              },
              "example": {
                "website_id": "123e4567-e89b-42d3-a456-426614174000",
                "filters": {
                  "start_date": "2026-10-01",
                  "end_date": "2026-10-31"
                },
                "page_num": 0,
                "page_size": 30
              }
            }
          }
        },
        "tags": [
          "Sources"
        ],
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/api/v1/sources/youtube-videos": {
      "post": {
        "operationId": "sources.youtubeVideos",
        "summary": "List YouTube Videos",
        "description": "List YouTube videos cited in AI answers for a website, ordered by citation count. Returns saved titles, channel details, categories, durations, publication dates, citation counts, distinct-response citation percentages and linked timestamps. Watch, Shorts and short-link variants of one video are combined. Filter by channel_key or video_id. Metadata may be pending or missing; no live YouTube fetch is performed. Dates are inclusive UTC days. Counts cover citations in Athena-tracked AI answers, not YouTube views or subscriber analytics. Metadata is read from Athena’s saved cache and may be unavailable. Channel share uses all YouTube citations, including non-video links; category and length shares use video citations. Video citation_percentage is the percentage of distinct filtered AI responses citing that video. first_seen is within the selected date range. The completed breakdown, including citation metrics and saved metadata, is cached for up to five minutes. The moments array contains seconds from the top 100 cited URL variants per video; it is not an exhaustive timestamp list or a transcript. channel_key and video_id narrow returned videos without changing the response denominator.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "videos": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "video_id": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "channel": {
                            "type": "object",
                            "properties": {
                              "channel_key": {
                                "type": "string",
                                "description": "Stable group key; use as channel_key in get_youtube_videos."
                              },
                              "channel_id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "handle": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "url": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "thumbnail_url": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "channel_key",
                              "channel_id",
                              "name",
                              "handle",
                              "url",
                              "thumbnail_url"
                            ],
                            "additionalProperties": false
                          },
                          "category_id": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "duration_seconds": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "published_at": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "first_seen": {
                            "type": "string"
                          },
                          "citations": {
                            "type": "number"
                          },
                          "citation_percentage": {
                            "type": "number"
                          },
                          "details_status": {
                            "type": "string",
                            "enum": [
                              "found",
                              "pending",
                              "missing"
                            ]
                          },
                          "moments": {
                            "type": "array",
                            "items": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991
                            },
                            "description": "Distinct linked timestamps in seconds, from the top 100 cited URL variants. This is a bounded list, not every timestamp or transcript."
                          }
                        },
                        "required": [
                          "video_id",
                          "url",
                          "title",
                          "channel",
                          "category_id",
                          "duration_seconds",
                          "published_at",
                          "first_seen",
                          "citations",
                          "citation_percentage",
                          "details_status",
                          "moments"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page_num": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "page_size": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "page_num",
                        "page_size",
                        "total"
                      ],
                      "additionalProperties": false
                    },
                    "notice": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "videos",
                    "pagination"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "filters": {
                    "type": "object",
                    "properties": {
                      "start_date": {
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
                        "description": "First day, YYYY-MM-DD, inclusive (UTC)."
                      },
                      "schedule_id": {
                        "description": "One schedule: \"default\" or a custom/archived schedule UUID. Omit for Default, which includes all pre-cutover history and ad hoc runs. The retired \"manual\" token is accepted as an alias of \"default\". Schedules cannot be combined.",
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "default",
                              "manual"
                            ]
                          },
                          {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        ]
                      },
                      "end_date": {
                        "description": "Last day, YYYY-MM-DD, inclusive (UTC). Defaults to today.",
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                      },
                      "models": {
                        "description": "AI models to include, as an array even for one model — e.g. [\"chatgpt\", \"perplexity\"]. Omit to include all models.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "chatgpt",
                            "perplexity",
                            "gemini",
                            "google_ai_overview",
                            "copilot",
                            "claude",
                            "ai_mode",
                            "grok",
                            "deepseek",
                            "meta_ai",
                            "mistral"
                          ]
                        }
                      },
                      "prompt_ids": {
                        "description": "Prompt UUIDs to filter to, as an array even for one id. Omit for all prompts.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "location_ids": {
                        "description": "Location UUIDs to filter to, as an array even for one id. The literal string \"no-location\" selects responses that ran without a location. Omit for all locations.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            {
                              "type": "string",
                              "const": "no-location"
                            }
                          ]
                        }
                      },
                      "persona_ids": {
                        "description": "Persona UUIDs to filter to, as an array even for one id. Omit for all personas.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "target_identifiers": {
                        "description": "Target identifier strings to filter to, as an array even for one value. The literal string \"no-identifier\" selects responses with no target identifier. Omit for all.",
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "string",
                              "const": "no-identifier"
                            }
                          ]
                        }
                      },
                      "variation_filter": {
                        "description": "Which prompt rows to include, as an array: \"prompt\" for base prompts, \"variation\" for generated variations, or both. Omit for both.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "variation",
                            "prompt"
                          ]
                        }
                      },
                      "prompt_tags": {
                        "description": "Prompt tag UUIDs from get_prompt_tags.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "prompt_tags_operator": {
                        "description": "How prompt_tags combine: \"is_any_of\" matches prompts with any listed tag, \"has_all_of\" only prompts carrying every listed tag.",
                        "type": "string",
                        "enum": [
                          "is_any_of",
                          "has_all_of"
                        ]
                      },
                      "prompt_status": {
                        "description": "Filter prompts by tracking status: \"active\" or \"paused\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "active",
                          "paused"
                        ]
                      },
                      "prompt_type": {
                        "description": "Filter prompts by type: \"branded\" (mentions the brand) or \"non_branded\". Omit for both.",
                        "type": "string",
                        "enum": [
                          "branded",
                          "non_branded"
                        ]
                      }
                    },
                    "required": [
                      "start_date"
                    ],
                    "additionalProperties": false
                  },
                  "page_num": {
                    "default": 0,
                    "description": "Zero-based page number.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "page_size": {
                    "default": 30,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  },
                  "channel_key": {
                    "description": "Channel group key from get_youtube_creators; omit for all creators.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "video_id": {
                    "description": "YouTube video ID; omit for all videos.",
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{11}$"
                  }
                },
                "required": [
                  "website_id",
                  "filters"
                ]
              },
              "example": {
                "website_id": "123e4567-e89b-42d3-a456-426614174000",
                "filters": {
                  "start_date": "2026-10-01",
                  "end_date": "2026-10-31"
                },
                "page_num": 0,
                "page_size": 30
              }
            }
          }
        },
        "tags": [
          "Sources"
        ],
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/api/v1/seo/recommendations": {
      "post": {
        "operationId": "seoRecommendations.submit",
        "summary": "Submit SEO recommendations",
        "description": "Submit one draft or public HTTPS page for asynchronous SEO and AI-search recommendations. The website's organization must have the seo_recommendations entitlement in Autumn, and the caller must have website content administration access. Missing entitlement returns 403; an unavailable entitlement check returns 500 without creating a job. Queued work is checked again before analysis. Reuse request_id with identical input for retries; changed input returns 409. A website may have 1,000 outstanding jobs, with up to four active analyses and 16 across all websites. The website submit ceiling is 120 requests/minute, subject to the organization-wide API budget (default 60 requests/minute shared by submissions, polling and other API calls). Honor Retry-After on 429. Pace submissions and reserve request budget for polling a bounded subset of jobs; do not poll an entire backlog every poll_after_seconds. Polling never starts another analysis.",
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "running", "completed", "failed"]
                    },
                    "contract_version": {
                      "enum": ["seo-recommendations/v1"],
                      "type": "string"
                    },
                    "poll_after_seconds": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "job_id",
                    "status",
                    "contract_version",
                    "poll_after_seconds"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited: honor Retry-After before retrying with the same request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "request_id": {
                    "type": "string"
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "enum": ["draft"],
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "meta_description": {
                            "type": "string"
                          },
                          "markdown": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "title",
                          "meta_description",
                          "markdown"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "enum": ["url"],
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          }
                        },
                        "required": ["kind", "url"]
                      }
                    ]
                  },
                  "target_queries": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "locale": {
                    "type": "string"
                  },
                  "local_context": {
                    "type": "string"
                  }
                },
                "required": ["website_id", "request_id", "source"]
              }
            }
          }
        },
        "tags": ["SEO Recommendations"]
      }
    },
    "/api/v1/seo/recommendations/{job_id}": {
      "get": {
        "operationId": "seoRecommendations.get",
        "summary": "Get SEO recommendation job",
        "description": "Read a saved job with website content view access (viewer or higher). Results can contain evidence from submitted drafts. A completed result contains source-grounded recommendations, source_digest, token usage and warnings. Dollar cost is explicitly unavailable. Pending jobs wait for worker capacity; queued time does not expire an analysis. A failed worker returns a structured error; submit a new request_id to retry. Poll a bounded subset of jobs and back off while status remains pending; polling shares the organization-wide API request budget.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "running", "completed", "failed"]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "result": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "contract_version": {
                              "enum": ["seo-recommendations/v1"],
                              "type": "string"
                            },
                            "source_digest": {
                              "type": "string"
                            },
                            "recommendations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "priority": {
                                    "type": "string",
                                    "enum": ["high", "medium", "low"]
                                  },
                                  "category": {
                                    "type": "string",
                                    "enum": ["seo", "aio"]
                                  },
                                  "title": {
                                    "type": "string"
                                  },
                                  "change": {
                                    "type": "string"
                                  },
                                  "evidence": {
                                    "type": "string"
                                  },
                                  "heading_path": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "required": [
                                  "id",
                                  "priority",
                                  "category",
                                  "title",
                                  "change",
                                  "evidence",
                                  "heading_path"
                                ]
                              }
                            },
                            "usage": {
                              "type": "object",
                              "properties": {
                                "input_characters": {
                                  "type": "integer"
                                },
                                "input_tokens": {
                                  "anyOf": [
                                    {
                                      "type": "integer"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "output_tokens": {
                                  "anyOf": [
                                    {
                                      "type": "integer"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "provider_cost_usd": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "cost_status": {
                                  "enum": ["unavailable"],
                                  "type": "string"
                                }
                              },
                              "required": [
                                "input_characters",
                                "input_tokens",
                                "output_tokens",
                                "provider_cost_usd",
                                "cost_status"
                              ]
                            },
                            "warnings": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "contract_version",
                            "source_digest",
                            "recommendations",
                            "usage",
                            "warnings"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": ["code", "message"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "job_id",
                    "status",
                    "created_at",
                    "completed_at",
                    "result",
                    "error"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited: honor Retry-After before retrying with the same request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "tags": ["SEO Recommendations"]
      }
    },
    "/api/v1/seo/issues": {
      "post": {
        "operationId": "seoIssues.list",
        "tags": ["Site Health"],
        "summary": "List Site Health issues",
        "description": "List a website's Site Health issues: one group per kind of problem (check) with its title, why it matters, severity (critical, warning, opportunity), priority (high, medium, low), owner (writer, developer or either; null when unknown), effort (minutes, hours, days), whether it is site-wide, counts of affected pages by status (open, in_progress, fixed, verified, dismissed), up to three sections it concentrates in, and sample affected pages with each page's detail, recommendation, evidence, assignee and task_revision. Filter by status, check, a search term, the stored URLs of specific pages (page_urls), or assignee \"me\" (signed-in connections only). Groups are paged: page is 0-based, page_size defaults to 25 (max 200) and total counts the groups that match; counts totals pages by status across the whole site, ignoring the status filter. A group carries at most 50 sample pages (10 when a tool calls it, which also caps page_size at 25); has_more_pages says to read the rest with the issue pages read (get_site_health_issue_pages or POST /v1/seo/issues/pages), whose page 0 repeats the sample pages. has_evidence false means the site has never been crawled or audited. Requires Site Health on the website's plan; otherwise the call fails with 403.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "in_progress",
                      "fixed",
                      "verified",
                      "dismissed"
                    ]
                  },
                  "check": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "assignee": {
                    "enum": ["me"],
                    "type": "string"
                  },
                  "page": {
                    "type": "integer"
                  },
                  "page_urls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "page_size": {
                    "type": "integer"
                  }
                },
                "required": ["website_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "groups": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "check": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "why_it_matters": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "owner": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["writer", "developer", "either"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "effort": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["minutes", "hours", "days"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "bucket": {
                            "type": "string",
                            "enum": [
                              "technical_cleanup",
                              "content_restructuring",
                              "content_enrichment"
                            ]
                          },
                          "severity": {
                            "type": "string",
                            "enum": ["critical", "warning", "opportunity"]
                          },
                          "priority": {
                            "type": "string",
                            "enum": ["high", "medium", "low"]
                          },
                          "site_wide": {
                            "type": "boolean"
                          },
                          "counts": {
                            "type": "object",
                            "properties": {
                              "open": {
                                "type": "integer"
                              },
                              "in_progress": {
                                "type": "integer"
                              },
                              "fixed": {
                                "type": "integer"
                              },
                              "verified": {
                                "type": "integer"
                              },
                              "dismissed": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "open",
                              "in_progress",
                              "fixed",
                              "verified"
                            ]
                          },
                          "sections": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "section": {
                                  "type": "string"
                                },
                                "open": {
                                  "type": "integer"
                                },
                                "audited": {
                                  "type": "integer"
                                }
                              },
                              "required": ["section", "open", "audited"]
                            }
                          },
                          "pages": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "finding_id": {
                                  "type": "string"
                                },
                                "page_id": {
                                  "type": "string"
                                },
                                "property_id": {
                                  "type": "string"
                                },
                                "url": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "open",
                                    "in_progress",
                                    "fixed",
                                    "verified",
                                    "dismissed"
                                  ]
                                },
                                "page_title": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "detail": {
                                  "type": "string"
                                },
                                "recommendation": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "shared_value": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "evidence": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "evidence_links": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "label": {
                                        "type": "string"
                                      },
                                      "url": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["label", "url"]
                                  }
                                },
                                "robots_txt_rule": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "url": {
                                          "type": "string"
                                        },
                                        "line": {
                                          "type": "integer"
                                        },
                                        "excerpt": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "line": {
                                                "type": "integer"
                                              },
                                              "text": {
                                                "type": "string"
                                              }
                                            },
                                            "required": ["line", "text"]
                                          }
                                        }
                                      },
                                      "required": ["url", "line", "excerpt"]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "first_seen_at": {
                                  "type": "string"
                                },
                                "last_seen_at": {
                                  "type": "string"
                                },
                                "resolved_at": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "last_checked_at": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "assignee": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "name": {
                                          "type": "string"
                                        }
                                      },
                                      "required": ["id", "name"]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "task_revision": {
                                  "type": "integer"
                                },
                                "draft": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "run_id": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string"
                                        }
                                      },
                                      "required": ["run_id", "status"]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "finding_id",
                                "page_id",
                                "property_id",
                                "url",
                                "status",
                                "page_title",
                                "detail",
                                "recommendation",
                                "shared_value",
                                "evidence",
                                "evidence_links",
                                "robots_txt_rule",
                                "first_seen_at",
                                "last_seen_at",
                                "resolved_at",
                                "last_checked_at",
                                "assignee",
                                "task_revision",
                                "draft"
                              ]
                            }
                          },
                          "has_more_pages": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "check",
                          "title",
                          "why_it_matters",
                          "owner",
                          "effort",
                          "bucket",
                          "severity",
                          "priority",
                          "site_wide",
                          "counts",
                          "sections",
                          "pages",
                          "has_more_pages"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "properties": {
                        "open": {
                          "type": "integer"
                        },
                        "in_progress": {
                          "type": "integer"
                        },
                        "fixed": {
                          "type": "integer"
                        },
                        "verified": {
                          "type": "integer"
                        },
                        "dismissed": {
                          "type": "integer"
                        }
                      },
                      "required": ["open", "in_progress", "fixed", "verified"]
                    },
                    "page_size": {
                      "type": "integer"
                    },
                    "has_evidence": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "groups",
                    "total",
                    "counts",
                    "page_size",
                    "has_evidence"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited: honor Retry-After before retrying",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/seo/issues/pages": {
      "post": {
        "operationId": "seoIssues.pages",
        "tags": ["Site Health"],
        "summary": "List the pages a Site Health issue affects",
        "description": "Page through every page one Site Health issue affects, 50 per page, open pages first and most recently seen first within a status. Give the check from the issue list; filter by status; page is 0-based and has_more says whether to continue; page 0 starts from the first affected page, so it repeats the sample pages the issue list showed inline. page_id returns that one page's row for the check. Each row carries the finding_id and task_revision an update of the page's task needs, the finding's detail, recommendation and evidence, the assignee, and the dates it was first and last seen and last checked. Requires Site Health on the website's plan; otherwise the call fails with 403.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "check": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "in_progress",
                      "fixed",
                      "verified",
                      "dismissed"
                    ]
                  },
                  "page": {
                    "type": "integer"
                  },
                  "page_id": {
                    "type": "string"
                  }
                },
                "required": ["website_id", "check"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "finding_id": {
                            "type": "string"
                          },
                          "page_id": {
                            "type": "string"
                          },
                          "property_id": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "open",
                              "in_progress",
                              "fixed",
                              "verified",
                              "dismissed"
                            ]
                          },
                          "page_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "detail": {
                            "type": "string"
                          },
                          "recommendation": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "shared_value": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "evidence": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "evidence_links": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "label": {
                                  "type": "string"
                                },
                                "url": {
                                  "type": "string"
                                }
                              },
                              "required": ["label", "url"]
                            }
                          },
                          "robots_txt_rule": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "url": {
                                    "type": "string"
                                  },
                                  "line": {
                                    "type": "integer"
                                  },
                                  "excerpt": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "line": {
                                          "type": "integer"
                                        },
                                        "text": {
                                          "type": "string"
                                        }
                                      },
                                      "required": ["line", "text"]
                                    }
                                  }
                                },
                                "required": ["url", "line", "excerpt"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "first_seen_at": {
                            "type": "string"
                          },
                          "last_seen_at": {
                            "type": "string"
                          },
                          "resolved_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_checked_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "assignee": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  }
                                },
                                "required": ["id", "name"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "task_revision": {
                            "type": "integer"
                          },
                          "draft": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "run_id": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string"
                                  }
                                },
                                "required": ["run_id", "status"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "finding_id",
                          "page_id",
                          "property_id",
                          "url",
                          "status",
                          "page_title",
                          "detail",
                          "recommendation",
                          "shared_value",
                          "evidence",
                          "evidence_links",
                          "robots_txt_rule",
                          "first_seen_at",
                          "last_seen_at",
                          "resolved_at",
                          "last_checked_at",
                          "assignee",
                          "task_revision",
                          "draft"
                        ]
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  },
                  "required": ["pages", "has_more"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited: honor Retry-After before retrying",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/seo/analytics": {
      "get": {
        "operationId": "seoAnalytics.site",
        "tags": ["Site Health"],
        "summary": "Get Site Health analytics",
        "description": "Live Google Analytics 4, Google Search Console and AI-citation figures for a website over the last 28 complete days, each beside the 28 days before (period gives both ranges; change_pct is null when the earlier period was zero). ga4: AI-referred sessions, their engagement rate and key events, organic and total sessions, AI share of sessions in percent, daily AI sessions, and the top 10 AI sources, AI landing pages and organic landing pages. gsc: clicks, impressions, CTR in percent and average position, a daily series, and the top 10 queries and pages. cited_pages: the website's pages AI answers cited most, with the Google figures for the same page. connected false means no Google property is linked for that provider; available false means it is linked but the read failed. Read live from Google, so a connection made a moment ago shows at once. Requires Site Health on the website's plan; otherwise the call fails with 403.",
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "period": {
                      "type": "object",
                      "properties": {
                        "start_date": {
                          "type": "string"
                        },
                        "end_date": {
                          "type": "string"
                        },
                        "previous_start_date": {
                          "type": "string"
                        },
                        "previous_end_date": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "start_date",
                        "end_date",
                        "previous_start_date",
                        "previous_end_date"
                      ]
                    },
                    "ga4": {
                      "type": "object",
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "available": {
                          "type": "boolean"
                        },
                        "property_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ai_sessions": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "ai_engagement_rate": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ai_key_events": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "organic_sessions": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "total_sessions": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "ai_share_pct": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ai_daily": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "date": {
                                "type": "string"
                              },
                              "value": {
                                "type": "number"
                              }
                            },
                            "required": ["date", "value"]
                          }
                        },
                        "sources": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "sessions": {
                                "type": "number"
                              },
                              "previous": {
                                "type": "number"
                              }
                            },
                            "required": ["name", "sessions", "previous"]
                          }
                        },
                        "ai_landing_pages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "url": {
                                "type": "string"
                              },
                              "sessions": {
                                "type": "number"
                              },
                              "previous": {
                                "type": "number"
                              }
                            },
                            "required": ["url", "sessions", "previous"]
                          }
                        },
                        "organic_landing_pages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "url": {
                                "type": "string"
                              },
                              "sessions": {
                                "type": "number"
                              },
                              "key_events": {
                                "type": "number"
                              }
                            },
                            "required": ["url", "sessions", "key_events"]
                          }
                        }
                      },
                      "required": [
                        "connected",
                        "available",
                        "property_name",
                        "ai_sessions",
                        "ai_engagement_rate",
                        "ai_key_events",
                        "organic_sessions",
                        "total_sessions",
                        "ai_share_pct",
                        "ai_daily",
                        "sources",
                        "ai_landing_pages",
                        "organic_landing_pages"
                      ]
                    },
                    "gsc": {
                      "type": "object",
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "available": {
                          "type": "boolean"
                        },
                        "site_url": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "clicks": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "impressions": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "ctr": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "position": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change_pct": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["current", "previous", "change_pct"]
                        },
                        "daily": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "date": {
                                "type": "string"
                              },
                              "clicks": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              }
                            },
                            "required": ["date", "clicks", "impressions"]
                          }
                        },
                        "queries": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "clicks": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "ctr": {
                                "type": "number"
                              },
                              "position": {
                                "type": "number"
                              },
                              "previous_clicks": {
                                "type": "number"
                              },
                              "query": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "clicks",
                              "impressions",
                              "ctr",
                              "position",
                              "previous_clicks",
                              "query"
                            ]
                          }
                        },
                        "pages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "clicks": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "ctr": {
                                "type": "number"
                              },
                              "position": {
                                "type": "number"
                              },
                              "previous_clicks": {
                                "type": "number"
                              },
                              "url": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "clicks",
                              "impressions",
                              "ctr",
                              "position",
                              "previous_clicks",
                              "url"
                            ]
                          }
                        }
                      },
                      "required": [
                        "connected",
                        "available",
                        "site_url",
                        "clicks",
                        "impressions",
                        "ctr",
                        "position",
                        "daily",
                        "queries",
                        "pages"
                      ]
                    },
                    "cited_pages": {
                      "type": "object",
                      "properties": {
                        "available": {
                          "type": "boolean"
                        },
                        "pages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "url": {
                                "type": "string"
                              },
                              "citations": {
                                "type": "number"
                              },
                              "prompts": {
                                "type": "number"
                              },
                              "ai_sessions": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "clicks": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "impressions": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "position": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "url",
                              "citations",
                              "prompts",
                              "ai_sessions",
                              "clicks",
                              "impressions",
                              "position"
                            ]
                          }
                        }
                      },
                      "required": ["available", "pages"]
                    }
                  },
                  "required": ["period", "ga4", "gsc", "cited_pages"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited: honor Retry-After before retrying",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/looker-studio/data": {
      "post": {
        "tags": ["Analytics"],
        "summary": "Query Looker Studio report data",
        "description": "Return report rows for one active website in your API key's organization and streaming schedule. Website-scoped keys must also include the website in their allowlist. Deleted websites return HTTP 403 even if their IDs remain in the key's allowlist. filters.schedule_id accepts default or a custom schedule UUID; omission selects Default. The retired manual token is accepted as an alias of default. Schedule selection applies to every metric and dimension and is part of the report cache key. Archived schedules retain history. Response-grain reports are bounded before response text hydration; narrow the filters if the row limit is exceeded.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "website_id",
                  "dimensions",
                  "metrics",
                  "filters",
                  "looker_studio_filters"
                ],
                "properties": {
                  "website_id": { "type": "string", "format": "uuid" },
                  "dimensions": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "date",
                        "model",
                        "company_name",
                        "is_self",
                        "location",
                        "topic_name",
                        "prompt",
                        "monthly_searches",
                        "response"
                      ]
                    }
                  },
                  "metrics": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "citation_rate",
                        "mention_rate",
                        "share_of_voice",
                        "position",
                        "mentions",
                        "citations",
                        "total_responses"
                      ]
                    }
                  },
                  "filters": {
                    "allOf": [
                      { "$ref": "#/components/schemas/ApiFilters" },
                      {
                        "type": "object",
                        "required": ["end_date"],
                        "properties": {
                          "prompt_tags": {
                            "type": "array",
                            "items": {
                              "oneOf": [
                                { "type": "string", "format": "uuid" },
                                {
                                  "type": "string",
                                  "enum": ["type:discovery", "type:high_intent"]
                                }
                              ]
                            }
                          },
                          "prompt_tags_operator": {
                            "type": "string",
                            "enum": ["is_any_of", "has_all_of"]
                          }
                        }
                      }
                    ]
                  },
                  "looker_studio_filters": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": ["fieldName", "operator", "type", "value"],
                        "properties": {
                          "fieldName": {
                            "type": "string",
                            "enum": [
                              "date",
                              "model",
                              "company_name",
                              "is_self",
                              "location",
                              "topic_name",
                              "prompt",
                              "monthly_searches",
                              "response",
                              "citation_rate",
                              "mention_rate",
                              "share_of_voice",
                              "position",
                              "mentions",
                              "citations",
                              "total_responses"
                            ]
                          },
                          "operator": {
                            "type": "string",
                            "enum": [
                              "EQUALS",
                              "CONTAINS",
                              "REGEXP_PARTIAL_MATCH",
                              "REGEXP_EXACT_MATCH",
                              "IN_LIST",
                              "IS_NULL",
                              "BETWEEN",
                              "NUMERIC_GREATER_THAN",
                              "NUMERIC_GREATER_THAN_OR_EQUAL",
                              "NUMERIC_LESS_THAN",
                              "NUMERIC_LESS_THAN_OR_EQUAL"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": ["INCLUDE", "EXCLUDE"]
                          },
                          "value": {
                            "type": "array",
                            "items": { "type": "string" }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Report rows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": { "type": "string" },
                          "model": { "type": "string" },
                          "company_name": { "type": "string" },
                          "is_self": { "type": "boolean" },
                          "location": { "type": "string" },
                          "topic_name": { "type": "string" },
                          "prompt": { "type": "string" },
                          "monthly_searches": { "type": ["integer", "null"] },
                          "response": { "type": "string" },
                          "citation_rate": { "type": "number" },
                          "mention_rate": { "type": "number" },
                          "share_of_voice": { "type": "number" },
                          "position": { "type": "number" },
                          "mentions": { "type": "number" },
                          "citations": { "type": "number" },
                          "total_responses": { "type": "number" }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or response report row limit exceeded"
          },
          "401": { "description": "Authentication required" },
          "403": { "description": "Website or filter resource access denied" },
          "404": { "description": "Website not found" }
        }
      }
    },
    "/api/v1/prompt-schedules": {
      "get": {
        "operationId": "promptSchedules.list",
        "summary": "List prompt schedules",
        "description": "List Default, custom and archived streaming schedules for a website. Use each row's selection value when filtering analytics or responses. Default includes all pre-cutover history and ad hoc runs. Select one schedule at a time; archived schedules retain results. Filters take one schedule; the metrics endpoints combine the schedules of a saved view stored with several schedules.",
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "format": "uuid" },
            "description": "ID of the website whose prompt schedules to list."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schedules": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": ["default", "custom"]
                          },
                          "selection": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["default"]
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "archived_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "starts_on": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "First UTC calendar day (YYYY-MM-DD) a custom schedule fires. Null means no lower bound. Always null on Default."
                          },
                          "ends_on": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last UTC calendar day (YYYY-MM-DD) a custom schedule fires. Null means no upper bound. An active schedule past this day does not run. Always null on Default."
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "kind",
                          "selection",
                          "is_active",
                          "archived_at",
                          "starts_on",
                          "ends_on"
                        ]
                      }
                    }
                  },
                  "required": ["schedules"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "tags": ["Basics"]
      }
    },
    "/api/validate-api-key": {
      "get": {
        "tags": ["Basics"],
        "summary": "Validate API Key",
        "description": "Validates an API key.",
        "operationId": "validateApiKey",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "API key validation result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "description": "Whether the API key is valid"
                    }
                  },
                  "required": ["valid"]
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "headers": {
              "x-rate-limit-limit": {
                "description": "The rate limit ceiling for the endpoint",
                "schema": {
                  "type": "string"
                }
              },
              "x-rate-limit-remaining": {
                "description": "The number of requests remaining in the current rate limit window",
                "schema": {
                  "type": "string"
                }
              },
              "x-rate-limit-reset": {
                "description": "The time at which the rate limit resets (Unix timestamp)",
                "schema": {
                  "type": "string"
                }
              },
              "retry-after": {
                "description": "The number of seconds to wait before retrying",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Rate limit exceeded"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/websites": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Websites",
        "description": "Returns all active websites associated with your API key. **Partner integrations** may pass `external_id` as a query parameter to find the Athena website mapped to a partner-supplied identifier.",
        "operationId": "getWebsites",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "**Partner-only.** Filter results to the website mapped to this partner-supplied identifier. Accepted only when authenticating with a partner API key \u2014 direct customers that pass this parameter receive `403 Forbidden`. Exact match, scoped to your organization; unmapped IDs return an empty array.",
            "example": "ws_a7f3b2c9"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of websites. Partner responses include an `externalId` field on each item (string or `null`); direct-customer responses omit the field entirely.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "websites": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Website"
                      }
                    }
                  },
                  "required": ["websites"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - `external_id` is partner-only; non-partner API keys cannot use this filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: partner API key required"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Basics"],
        "summary": "Create Website",
        "description": "Creates a new website in your organization. Requires a global API key; website-scoped keys return HTTP 403 before any resources are created. The website will be created with onboarding step 1, ready for further configuration. **Partner integrations** may include an `external_id` to map their own identifier onto the new Athena website. A successful creation also provisions the website's Default prompt schedule in the same transaction. Tracking patterns preserve the submitted host, path case, and query parameters. An apex such as acme.com includes www.acme.com; an explicit www.acme.com tracks only that host. Paths include the named section and descendants on slash boundaries. Domain matching is case-insensitive; path and query values are case-sensitive.",
        "operationId": "createWebsite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebsiteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Website created successfully. Partner responses include an `externalId` field (string or `null`); direct-customer responses omit the field entirely.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "website": {
                      "$ref": "#/components/schemas/CreatedWebsite"
                    },
                    "billingEntityCreated": {
                      "type": "boolean",
                      "description": "Whether the billing entity exists after provisioning. When false, entity creation failed even after a retry: the website exists but has no credits, and setting credits fails with a 400 until it is repaired. Contact AthenaHQ support in that case."
                    }
                  },
                  "required": ["website", "billingEntityCreated"]
                },
                "example": {
                  "website": {
                    "id": "123e4567-e89b-12d3-a456-426614174000",
                    "websiteUrl": "example.com",
                    "orgId": "987e6543-e21b-12d3-a456-426614174000",
                    "onboardingStep": 1
                  },
                  "billingEntityCreated": true
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_json": {
                    "value": {
                      "error": "Invalid JSON in request body"
                    }
                  },
                  "missing_url": {
                    "value": {
                      "error": "url: Required"
                    }
                  },
                  "invalid_url": {
                    "value": {
                      "error": "url: Invalid url"
                    }
                  },
                  "email_as_url": {
                    "value": {
                      "error": "Enter your website address, not an email address."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - A global API key is required. The `external_id` field additionally requires a partner API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "scoped_key": {
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "partner_required": {
                    "value": {
                      "error": "Forbidden: partner API key required"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - (partners only) the supplied `external_id` is already mapped to another website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalIdConflictError"
                },
                "examples": {
                  "external_id_conflict": {
                    "summary": "Partner external_id already mapped",
                    "value": {
                      "error": "external_id_conflict",
                      "message": "external_id ws_a7f3b2c9 is already mapped to a website",
                      "existing": {
                        "id": "123e4567-e89b-12d3-a456-426614174000",
                        "externalId": "ws_a7f3b2c9"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/websites/provision": {
      "post": {
        "tags": ["Basics"],
        "summary": "Provision Website",
        "x-beta": true,
        "description": "Creates a fully configured website in a single call, skipping the onboarding wizard. Optionally configures competitors, prompts, and a processing schedule. Requires a global API key. **Partner integrations** may include an `external_id` to map their own identifier onto the new Athena website. A successful creation also provisions the website's Default prompt schedule in the same transaction.\n\n> **Beta**: This endpoint is in beta. The request and response schemas may change. Website and competitor tracking patterns preserve the submitted host, path case, and query constraints. Apex domains include their www form; explicit www hosts remain distinct. Paths match sections on slash boundaries.",
        "operationId": "provisionWebsite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProvisionWebsiteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Website provisioned successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "website": {
                      "$ref": "#/components/schemas/ProvisionedWebsite"
                    },
                    "billingEntityCreated": {
                      "type": "boolean",
                      "description": "Whether the billing entity exists after provisioning. When false, entity creation failed even after a retry: the website exists but has no credits, and setting credits fails with a 400 until it is repaired. Contact AthenaHQ support in that case."
                    }
                  },
                  "required": ["website", "billingEntityCreated"]
                },
                "example": {
                  "website": {
                    "id": "123e4567-e89b-12d3-a456-426614174000",
                    "url": "acme.com",
                    "name": "Acme Corp",
                    "orgId": "987e6543-e21b-12d3-a456-426614174000",
                    "promptCount": 2,
                    "competitorCount": 1,
                    "hasSchedule": true
                  },
                  "billingEntityCreated": true
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_json": {
                    "value": {
                      "error": "Invalid JSON body"
                    }
                  },
                  "missing_url": {
                    "value": {
                      "error": "url: String must contain at least 1 character(s)"
                    }
                  },
                  "missing_name": {
                    "value": {
                      "error": "name: String must contain at least 1 character(s)"
                    }
                  },
                  "invalid_prompt_type": {
                    "value": {
                      "error": "prompts.0.type: Invalid enum value. Expected 'discovery' | 'high_intent', received 'invalid'"
                    }
                  },
                  "email_as_url": {
                    "value": {
                      "error": "url: Enter your website address, not an email address."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Requires a global API key, or (partner-only field) the key lacks partner identity for an `external_id`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "global_required": {
                    "summary": "Global API key required",
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "partner_required": {
                    "summary": "Partner API key required for external_id",
                    "value": {
                      "error": "Forbidden: partner API key required"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - (partners only) the supplied `external_id` is already mapped to another website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalIdConflictError"
                },
                "examples": {
                  "external_id_conflict": {
                    "summary": "Partner external_id already mapped",
                    "value": {
                      "error": "external_id_conflict",
                      "message": "external_id ws_a7f3b2c9 is already mapped to a website",
                      "existing": {
                        "id": "123e4567-e89b-12d3-a456-426614174000",
                        "externalId": "ws_a7f3b2c9"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/prompts": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Prompts",
        "description": "Returns all prompts for a specific website. You can optionally filter by status (active or paused). The prompts returned include metadata such as monthly search volume and total value.",
        "operationId": "getPrompts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve prompts for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter prompts by status. If omitted, returns both active and paused prompts.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          },
          {
            "name": "prompt_tags",
            "in": "query",
            "description": "Filter prompts by tag. Pass one or more prompt tag IDs (UUIDs). When omitted, prompts are not filtered by tag. Combine with `prompt_tags_operator` to control how multiple tags are matched. All tag IDs must belong to the same website as `website_id`, otherwise the request is rejected with `403`.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          {
            "name": "prompt_tags_operator",
            "in": "query",
            "description": "How to combine the `prompt_tags` filter. `is_any_of` (default) returns prompts carrying at least one of the given tags; `has_all_of` returns only prompts carrying every given tag. Ignored when `prompt_tags` is omitted.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["is_any_of", "has_all_of"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of prompts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "prompts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Prompt"
                      }
                    }
                  },
                  "required": ["prompts"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_status": {
                    "value": {
                      "error": "status must be 'active' or 'paused'"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - Rate limit exceeded. Retry after a short delay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Basics"],
        "summary": "Create Prompts",
        "description": "Creates one or more prompts on a website. Returns the created prompt ids. Each prompt's geography (`countries` / `primary_country`) and any attached `location_ids` are validated for compatibility before insert.",
        "operationId": "createPrompts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id", "prompts"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Website to create the prompts on."
                  },
                  "prompts": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 1000,
                    "items": {
                      "type": "object",
                      "required": ["prompt"],
                      "properties": {
                        "prompt": {
                          "type": "string",
                          "description": "Prompt text. Trimmed; empty / whitespace-only is rejected.",
                          "example": "best project management software",
                          "maxLength": 2000
                        },
                        "type": {
                          "type": "string",
                          "enum": ["discovery", "high_intent"],
                          "nullable": true,
                          "description": "Prompt type. Omitted/null is inferred from the text.",
                          "example": "discovery"
                        },
                        "volume": {
                          "type": "string",
                          "nullable": true,
                          "description": "Free-text volume label.",
                          "example": "1000"
                        },
                        "current_monthly_searches": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 0,
                          "maximum": 2147483647,
                          "description": "Estimated monthly searches. Fractional input is rounded to an integer; out-of-range returns 400.",
                          "example": 5400
                        },
                        "current_total_value": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 0,
                          "description": "Estimated total monthly value. Fractional input is rounded to an integer.",
                          "example": 1250
                        },
                        "topic_id": {
                          "type": "string",
                          "format": "uuid",
                          "nullable": true,
                          "description": "Topic to assign the prompt to."
                        },
                        "countries": {
                          "type": "array",
                          "maxItems": 1000,
                          "nullable": true,
                          "items": {
                            "type": "string"
                          },
                          "description": "Supported country names (case-insensitive; stored as canonical labels).",
                          "example": ["United States", "France"]
                        },
                        "primary_country": {
                          "type": "string",
                          "nullable": true,
                          "description": "Primary country. When `countries` is non-empty it must be one of them.",
                          "example": "United States"
                        },
                        "persona_ids": {
                          "type": "array",
                          "maxItems": 1000,
                          "nullable": true,
                          "items": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "description": "Persona ids to associate."
                        },
                        "location_ids": {
                          "type": "array",
                          "maxItems": 1000,
                          "nullable": true,
                          "items": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "description": "Location ids to associate. A location's country must be compatible with the prompt's countries."
                        },
                        "tag_ids": {
                          "type": "array",
                          "maxItems": 1000,
                          "nullable": true,
                          "items": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "description": "Tag ids to assign."
                        },
                        "is_paused": {
                          "type": "boolean",
                          "description": "Create the prompt paused (preserves paused state on import). Defaults to active.",
                          "default": false
                        }
                      }
                    }
                  },
                  "source": {
                    "type": "string",
                    "enum": ["manual", "ai_generated", "bulk_upload"],
                    "description": "Attribution source (UI server action only; ignored for API-key callers)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Prompts created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "count", "prompt_ids"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "count": {
                      "type": "integer",
                      "example": 1
                    },
                    "prompt_ids": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "blank_text": {
                    "value": {
                      "error": "Prompt text is required"
                    }
                  },
                  "unsupported_country": {
                    "value": {
                      "error": "Unsupported country: Atlantis"
                    }
                  },
                  "primary_not_in_countries": {
                    "value": {
                      "error": "Primary country must be one of the prompt's countries"
                    }
                  },
                  "location_country_mismatch": {
                    "value": {
                      "error": "A prompt's countries must include each attached location's country"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Prompt creation is limited to 60 requests per minute per website, independent of the organization-level API rate limit. Each request accepts up to 1,000 prompts, so batching keeps effective throughput at roughly 60,000 prompts per minute per website.",
            "headers": {
              "retry-after": {
                "description": "The number of seconds to wait before retrying",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Rate limit exceeded"
                    },
                    "retryAfterMs": {
                      "type": "integer",
                      "description": "Milliseconds to wait before retrying",
                      "example": 60000
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/prompt-tags": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Prompt Tags",
        "description": "Returns all prompt tags for a specific website, sorted by tag name, with the number of non-deleted prompts carrying each tag. Use the returned IDs with the `prompt_tags` filter on GET /api/v1/prompts or the `tag_ids` field on POST /api/v1/prompts.",
        "operationId": "getPromptTags",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve prompt tags for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of prompt tags",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "prompt_tags": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PromptTagWithCount"
                      }
                    }
                  },
                  "required": ["prompt_tags"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/personas": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Personas",
        "description": "Returns all personas for a specific website, sorted by name, with the number of non-deleted prompts each persona is assigned to. Use the returned IDs to resolve `persona_id` values returned by other endpoints and tools to persona names and descriptions.",
        "operationId": "getPersonas",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve personas for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of personas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "personas": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PersonaWithCount"
                      }
                    }
                  },
                  "required": ["personas"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/prompts/{prompt_id}": {
      "patch": {
        "tags": ["Basics"],
        "summary": "Update Prompt",
        "description": "Updates a prompt's metadata (text, type, volume, topic, geography, locations). Only the supplied fields change. Returns a before/after snapshot.\n\nA prompt's **text** (`prompt`) can only be changed while the prompt has not streamed any responses yet. Once it has responses, sending a changed `prompt` returns `400` \u2014 delete the prompt and create a new one instead. All other fields (type, volume, topic, geography, locations) remain editable at any time, and re-sending the existing text unchanged is always allowed.",
        "operationId": "updatePrompt",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "prompt_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The prompt to update."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Website that owns the prompt."
                  },
                  "prompt": {
                    "type": "string",
                    "description": "New prompt text. Trimmed; blank is rejected. Editable only while the prompt has no responses yet \u2014 changing it after responses have streamed returns `400`. Re-sending the current text unchanged (e.g. in a full-object PATCH) is always allowed, as are metadata-only edits.",
                    "maxLength": 2000
                  },
                  "type": {
                    "type": "string",
                    "enum": ["discovery", "high_intent"],
                    "nullable": true
                  },
                  "volume": {
                    "type": "string",
                    "nullable": true
                  },
                  "topic_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true
                  },
                  "countries": {
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "type": "string"
                    }
                  },
                  "primary_country": {
                    "type": "string",
                    "nullable": true,
                    "description": "When `countries` is non-empty it must be one of them."
                  },
                  "location_ids": {
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Prompt updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "text": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "nullable": true
                    },
                    "volume": {
                      "type": "string",
                      "nullable": true
                    },
                    "topic_id": {
                      "type": "string",
                      "nullable": true
                    },
                    "locations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "countries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "before": {
                      "type": "object",
                      "description": "Pre-update snapshot.",
                      "properties": {
                        "text": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "nullable": true
                        },
                        "volume": {
                          "type": "string",
                          "nullable": true
                        },
                        "topic_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "countries": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "location_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "text_edit_after_responses": {
                    "summary": "Text change blocked \u2014 prompt already has responses",
                    "value": {
                      "error": "Prompt text cannot be edited once the prompt has responses. Delete the prompt and create a new one with the updated text."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Prompt not found, deleted, or on another website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": "Prompt not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Basics"],
        "summary": "Delete Prompt",
        "description": "Deletes a prompt. Soft-deletes when the prompt already has responses, otherwise hard-deletes.",
        "operationId": "deletePrompt",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "prompt_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The prompt to delete."
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Website that owns the prompt."
          }
        ],
        "responses": {
          "200": {
            "description": "Prompt deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "soft_deleted"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "soft_deleted": {
                      "type": "boolean",
                      "description": "True when soft-deleted (had responses); false when hard-deleted."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Prompt not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": "Prompt not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/prompts/status": {
      "patch": {
        "tags": ["Basics"],
        "summary": "Pause or Unpause Prompts",
        "description": "Pauses or unpauses multiple prompts in one transaction.",
        "operationId": "setPromptsStatus",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id", "prompt_ids", "status"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "prompt_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 1000,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "status": {
                    "type": "string",
                    "enum": ["active", "paused"],
                    "description": "`paused` to pause, `active` to unpause."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Status updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message",
                    "changed_count",
                    "unchanged_count"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Paused 1 prompt"
                    },
                    "changed_count": {
                      "type": "integer",
                      "example": 1
                    },
                    "unchanged_count": {
                      "type": "integer",
                      "example": 0
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/topics": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Topics",
        "description": "Returns the active topics for a website, with the count of active prompts in each. Use it to resolve a topic name to its `id` before creating prompts or filtering.",
        "operationId": "getTopics",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve topics for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of topics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["topics"],
                  "properties": {
                    "topics": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "description",
                          "prompt_count"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": ["string", "null"]
                          },
                          "prompt_count": {
                            "type": "integer",
                            "description": "Number of active prompts in the topic."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "website_id is required"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Basics"],
        "summary": "Create Topic",
        "description": "Creates a topic on a website. Topics group prompts for aggregate reporting; pass the returned `id` as `prompts[].topic_id` when creating prompts. Get-or-create by name: if an active topic with the same name already exists, the existing topic is returned with `created: false` instead of failing, so retries and re-imports are idempotent.",
        "operationId": "createTopic",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id", "name"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "Topic name. Trimmed; blank rejected.",
                    "example": "Brand awareness"
                  },
                  "description": {
                    "type": ["string", "null"],
                    "maxLength": 2000,
                    "description": "Optional topic description."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Topic created (or existing topic returned when the name was already taken)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["id", "name", "description", "created"],
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "type": ["string", "null"]
                    },
                    "created": {
                      "type": "boolean",
                      "description": "False when an existing active topic with the same name was returned instead of creating a new one."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "blank_name": {
                    "value": {
                      "error": "Topic name is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/topics/{topic_id}": {
      "patch": {
        "tags": ["Basics"],
        "summary": "Update Topic",
        "description": "Updates a topic's name and/or description. Only the supplied fields change. Renaming to a name already used by another active topic on the website returns `400`. Renames don't affect metrics or prompt grouping \u2014 everything joins on the topic's `id`, not its name. Returns a before/after snapshot.",
        "operationId": "updateTopic",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "topic_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The topic to update."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Website that owns the topic."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "New topic name. Trimmed; blank rejected."
                  },
                  "description": {
                    "type": ["string", "null"],
                    "maxLength": 2000,
                    "description": "New topic description. Send null to clear."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Topic updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["id", "name", "description", "before"],
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "type": ["string", "null"]
                    },
                    "before": {
                      "type": "object",
                      "description": "Pre-update snapshot.",
                      "required": ["name", "description"],
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": ["string", "null"]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "duplicate_name": {
                    "value": {
                      "error": "A topic named \"Brand awareness\" already exists on this website"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Topic not found, deleted, or on another website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": "Topic not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Basics"],
        "summary": "Delete Topic",
        "description": "Soft-deletes a topic. By default its prompts are kept: they stay active, keep their history, remain grouped under the deleted topic in the app, and can be re-categorized later. Pass `delete_prompts=true` to also soft-delete every active prompt in the topic (they stop generating responses). Reversible: creating a topic with the same name restores it and its prompt grouping.",
        "operationId": "deleteTopic",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "topic_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The topic to delete."
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Website that owns the topic."
          },
          {
            "name": "delete_prompts",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["true", "false"]
            },
            "description": "When \"true\", also soft-deletes every active prompt in the topic. Defaults to \"false\" (prompts are kept)."
          }
        ],
        "responses": {
          "200": {
            "description": "Topic deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "name", "deleted_prompt_count"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [true]
                    },
                    "name": {
                      "type": "string",
                      "description": "Name of the deleted topic."
                    },
                    "deleted_prompt_count": {
                      "type": "integer",
                      "description": "Number of prompts soft-deleted alongside the topic (0 unless delete_prompts=true)."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Topic not found, deleted, or on another website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": "Topic not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitors": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Competitors",
        "description": "Returns the competitors tracked for a website. With `include_discovered=true`, also returns `discovered_competitors`: brands Athena found in the website's AI responses that the website does not track.",
        "operationId": "getCompetitors",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve competitors for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "include_discovered",
            "in": "query",
            "required": false,
            "description": "Set to `true` to add `discovered_competitors` to the response. When omitted or `false`, the response holds only `competitors`.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of competitors",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "competitors": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Competitor"
                      }
                    },
                    "discovered_competitors": {
                      "type": "array",
                      "description": "Returned only when `include_discovered` is `true`: up to 6 discovered competitors, highest mention rate first. An empty array when there are none.",
                      "items": {
                        "$ref": "#/components/schemas/DiscoveredCompetitor"
                      }
                    }
                  },
                  "required": ["competitors"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "website_id is required"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/identifiers": {
      "get": {
        "tags": [
          "Basics"
        ],
        "summary": "Get Identifiers",
        "description": "Returns the identifiers of a website's own brand, or of one of its competitors when you pass `competitor_id`: the names, aliases and domains Athena looks for in AI responses to count a mention. `default_identifiers` holds the name and domain, which are always matched. `identifiers` holds every other value the Competitors page shows, so the two lists together are the full set. `case_sensitive` tells whether matching respects letter case. `entity` says what the identifiers belong to, with `type` set to `brand` or `competitor`.",
        "operationId": "identifiers.get",
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The ID of the website"
          },
          {
            "name": "competitor_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The ID of a competitor on this website, as `GET /api/v1/competitors` returns it. Omit it for the website's own brand."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the identifiers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entity": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "brand",
                            "competitor"
                          ]
                        },
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "id",
                        "name",
                        "url"
                      ]
                    },
                    "default_identifiers": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "identifiers": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "case_sensitive": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "entity",
                    "default_identifiers",
                    "identifiers",
                    "case_sensitive"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - The competitor doesn't exist on this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/date-range": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Date Range",
        "description": "Returns the date range with available data for one streaming schedule's prompts. Omitting schedule_id selects Default, including all pre-cutover history.",
        "operationId": "getDateRange",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve the date range for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "schedule_id",
            "in": "query",
            "required": false,
            "schema": { "$ref": "#/components/schemas/PromptScheduleSelection" }
          },
          {
            "name": "prompt_status",
            "in": "query",
            "description": "Filter by prompt status. If omitted, includes all prompts (active and paused).",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with date range",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "min_date": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true,
                      "description": "The earliest timestamp with available data (UTC)",
                      "example": "2024-01-15T08:20:17.844Z"
                    },
                    "max_date": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true,
                      "description": "The latest timestamp with available data (UTC)",
                      "example": "2024-12-01T14:30:45.123Z"
                    }
                  },
                  "required": ["min_date", "max_date"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_status": {
                    "value": {
                      "error": "prompt_status must be 'active' or 'paused'"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/locations": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Locations",
        "description": "Returns all locations for a specific website.",
        "operationId": "getLocations",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve locations for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of locations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "locations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Location"
                      }
                    }
                  },
                  "required": ["locations"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "website_id is required"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Basics"],
        "summary": "Create Location",
        "description": "Creates a location for a website. `country` is case-insensitive and stored as its canonical label. Any attached `prompt_ids` must allow the location's country.",
        "operationId": "createLocation",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id", "location", "country"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "location": {
                    "type": "string",
                    "description": "Location name. Trimmed; blank rejected.",
                    "example": "New York"
                  },
                  "country": {
                    "type": "string",
                    "description": "Supported country (case-insensitive).",
                    "example": "United States"
                  },
                  "prompt_ids": {
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Active prompt ids to attach."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Location created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["id", "location", "country"],
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "location": {
                      "type": "string"
                    },
                    "country": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_country": {
                    "value": {
                      "error": "Unsupported country"
                    }
                  },
                  "blank_name": {
                    "value": {
                      "error": "Location name is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/locations/{location_id}": {
      "patch": {
        "tags": ["Basics"],
        "summary": "Update Location",
        "description": "Updates a location's name, country, and/or prompt associations. Only supplied fields change; omitting `prompt_ids` preserves existing associations. Returns a before/after snapshot.",
        "operationId": "updateLocation",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "location_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The location to update."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "location": {
                    "type": "string",
                    "description": "New name. Trimmed; blank rejected."
                  },
                  "country": {
                    "type": "string",
                    "description": "New country (case-insensitive, supported)."
                  },
                  "prompt_ids": {
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Replace active associations. Omit to keep existing; `[]` clears them."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Location updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["id", "location"],
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "location": {
                      "type": "string"
                    },
                    "country": {
                      "type": "string",
                      "nullable": true
                    },
                    "before": {
                      "type": "object",
                      "properties": {
                        "location": {
                          "type": "string"
                        },
                        "country": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Location not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": "Location not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Basics"],
        "summary": "Delete Location",
        "description": "Soft-deletes a location.",
        "operationId": "deleteLocation",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "location_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The location to delete."
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Website that owns the location."
          }
        ],
        "responses": {
          "200": {
            "description": "Location deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "location"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "location": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_access": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Location not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": "Location not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/response-streaming/start": {
      "post": {
        "tags": ["Basics"],
        "summary": "Start Response Streaming",
        "description": "Run tracked prompts against external AI providers to collect new responses for a website. Sends prompt text to the selected providers, stores their responses in AthenaHQ, and consumes response credits. Starts immediately; use only for a user-requested run. Returns a workflow_id; poll GET /api/v1/response-streaming/status for progress. Requires a website-admin API key.",
        "operationId": "startResponseStreaming",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["website_id"],
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Website to run the response streaming for."
                  },
                  "schedule_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Schedule UUID to attribute this run to and take prompt selectors from. A nonempty prompt_ids selection overrides those selectors. Omit to attribute the run to Default and run every active prompt unless prompt_ids is supplied. Explicit model, fan-out, persona and location choices apply to this run. The schedule must belong to this website and must not be archived."
                  },
                  "prompt_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Specific tracked prompt UUIDs to run, from 1 to 1,000. Overrides schedule prompt selectors when supplied. Omit to use schedule_id selectors, or every active prompt when schedule_id is also omitted. Paused prompts are skipped."
                  },
                  "selected_models": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "boolean"
                    },
                    "description": "Map of model id to enabled flag (e.g. `{ \"ai_overview\": true, \"ai_mode\": false }`). Model ids: `chatgpt`, `ai_overview` (Google AI Overviews; `google_ai_overview`, its name in the model filters, is also accepted), `perplexity`, `gemini`, `copilot`, `ai_mode`, `grok`, `claude`, `deepseek`, `meta_ai`, `mistral`. Omit to run every currently active model \u2014 this is not the dashboard's saved default selection. An id set to `true` that names no model is rejected with 400, as is an explicit selection that resolves to no available models."
                  },
                  "prompt_variations": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10,
                    "description": "Number of paraphrased variations to generate per prompt (0\u201310)."
                  },
                  "use_personas": {
                    "type": "boolean",
                    "description": "Whether to run the prompts through configured personas."
                  },
                  "use_locations": {
                    "type": "boolean",
                    "description": "Whether to run the prompts across the website's configured locations."
                  },
                  "only_locations": {
                    "type": "boolean",
                    "description": "When true, skip the base (non-localized) run and execute only the location-scoped variants. Requires `use_locations: true`: sending `only_locations: true` without `use_locations: true` queues nothing (the base run is skipped and no location variants are added), so the run completes as a no-op."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Run started",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workflow_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["running"]
                    }
                  },
                  "required": ["workflow_id", "status"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Admin access to this website is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - A response-streaming run is already in progress for this website. Poll GET /api/v1/response-streaming/status and retry once it is no longer `running`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "A response-streaming run is already in progress for this website"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - Rate limit exceeded. Retry after a short delay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/response-streaming/status": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Response Streaming Status",
        "description": "Returns the whole-run state and response-queue progress of a website's response-streaming run. By default reports the latest run; pass `workflow_id` to read a specific one. Progress measures response collection only, so `state` can remain `running` when `progress.percentage` is 100 while downstream analysis finishes. Only `state: \"completed\"` means the whole run, including downstream analysis, has finished. `saved_response_progress` separately counts distinct saved responses against the original request, with an immutable first-terminal-outcome snapshot. When no run has ever been started, `state` is `idle` and the config/progress fields are zeroed or null.",
        "operationId": "getResponseStreamingStatus",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "description": "The ID of the website to read run status for.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "workflow_id",
            "in": "query",
            "required": false,
            "description": "Read a specific run instead of the latest one.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current run state and progress",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "state": {
                      "type": "string",
                      "description": "Whole-run state. Only `completed` means the whole run, including downstream analysis, has finished. `running` can coexist with 100 percent response progress.",
                      "enum": [
                        "idle",
                        "running",
                        "completed",
                        "failed",
                        "cancelled"
                      ]
                    },
                    "workflow_id": {
                      "type": "string",
                      "nullable": true
                    },
                    "created_at": {
                      "type": "string",
                      "nullable": true
                    },
                    "updated_at": {
                      "type": "string",
                      "nullable": true
                    },
                    "is_scheduled": {
                      "type": "boolean",
                      "nullable": true
                    },
                    "finish_reason": {
                      "type": "string",
                      "description": "Why a `failed` or `cancelled` run ended. `credits_exhausted`: no credits remaining. `credits_paused`: credit allocation paused by the partner. `subscription_inactive`, `organization_deleted`. `entitlement_unreadable`: billing could not be read mid-run; pending responses are retried by the backfill. `cancelled_by_user`. `responses_failed`: collection finished with failed responses. `items_stuck`, `attribute_extraction_failed`, `workflow_error`, `stale`. Null while running, for completed runs, and for runs older than this field.",
                      "enum": [
                        "credits_exhausted",
                        "credits_paused",
                        "subscription_inactive",
                        "organization_deleted",
                        "entitlement_unreadable",
                        "cancelled_by_user",
                        "responses_failed",
                        "items_stuck",
                        "attribute_extraction_failed",
                        "workflow_error",
                        "stale"
                      ],
                      "nullable": true
                    },
                    "config": {
                      "type": "object",
                      "properties": {
                        "mode": {
                          "type": "string",
                          "enum": ["all_prompts", "selected_prompts"],
                          "nullable": true
                        },
                        "selected_prompt_count": {
                          "type": "integer",
                          "nullable": true
                        },
                        "models": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "boolean"
                          },
                          "nullable": true
                        },
                        "prompt_variations": {
                          "type": "integer",
                          "nullable": true
                        },
                        "use_personas": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "use_locations": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "only_locations": {
                          "type": "boolean",
                          "nullable": true
                        }
                      },
                      "required": [
                        "mode",
                        "selected_prompt_count",
                        "models",
                        "prompt_variations",
                        "use_personas",
                        "use_locations",
                        "only_locations"
                      ]
                    },
                    "progress": {
                      "type": "object",
                      "description": "Measures response collection only. These queue counts do not indicate downstream analysis readiness.",
                      "properties": {
                        "pending": {
                          "type": "integer"
                        },
                        "processing": {
                          "type": "integer"
                        },
                        "completed": {
                          "type": "integer"
                        },
                        "failed": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "percentage": {
                          "type": "number",
                          "description": "Percentage of response-queue items completed or failed. A value of 100 does not indicate downstream analysis readiness.",
                          "minimum": 0,
                          "maximum": 100
                        }
                      },
                      "required": [
                        "pending",
                        "processing",
                        "completed",
                        "failed",
                        "total",
                        "percentage"
                      ]
                    },
                    "saved_response_progress": {
                      "type": "object",
                      "nullable": true,
                      "description": "Cached retained-response counts, separate from execution-queue progress. Null means no original request plan was recorded. Check completed_count_observed_at before interpreting the count; a missing observation means unknown, not zero. Recovery can increase the current count, and response deletion can reduce it. Initial fields preserve the snapshot available at first finalization.",
                      "properties": {
                        "planned_count": { "type": "integer", "minimum": 0 },
                        "expected_count": {
                          "type": "integer",
                          "minimum": 0,
                          "nullable": true,
                          "description": "Every planned base request plus the prompt variations that generation actually produced, frozen when original population completes. Lower than planned_count when variation generation fell short. Null means the population never completed; zero means a measured empty run."
                        },
                        "completed_count": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Best-effort snapshot of retained saved responses, including recovery and accepted late results. Only measured when completed_count_observed_at is present."
                        },
                        "completed_count_observed_at": {
                          "type": "string",
                          "nullable": true,
                          "description": "Count observation timestamp. Null or absent means unknown. Counts may remain stale during refresh failure; status reads never start a recount."
                        },
                        "population_completed_at": {
                          "type": "string",
                          "nullable": true,
                          "description": "Original population completion timestamp. Backfill never replaces this boundary."
                        },
                        "initial_completed_count": {
                          "type": "integer",
                          "minimum": 0,
                          "nullable": true,
                          "description": "Last observed count frozen at the first terminal outcome. Null if population or the count snapshot was unmeasured. This is not an exact count at finalization."
                        },
                        "initial_completed_count_observed_at": {
                          "type": "string",
                          "nullable": true,
                          "description": "Observation time of the frozen initial count. It can precede initial_terminal_at."
                        },
                        "initial_status": {
                          "type": "string",
                          "enum": ["completed", "failed", "cancelled"],
                          "nullable": true
                        },
                        "initial_terminal_at": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "planned_count",
                        "expected_count",
                        "completed_count",
                        "population_completed_at",
                        "initial_completed_count",
                        "initial_status",
                        "initial_terminal_at"
                      ]
                    }
                  },
                  "required": [
                    "state",
                    "workflow_id",
                    "config",
                    "progress",
                    "saved_response_progress"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - Rate limit exceeded. Retry after a short delay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/responses": {
      "post": {
        "tags": ["Basics"],
        "summary": "Query Responses",
        "description": "Returns paginated AI model responses for a website with optional filtering by date range, models, prompts, competitors, and the search queries used to produce each response.",
        "operationId": "queryResponses",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with list of responses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "responses": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Response"
                      }
                    }
                  },
                  "required": ["responses"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_json": {
                    "value": {
                      "error": "Invalid JSON in request body"
                    }
                  },
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website, prompts, or competitors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "unauthorized_prompts": {
                    "value": {
                      "error": "Unauthorized access to these prompts"
                    }
                  },
                  "unauthorized_competitors": {
                    "value": {
                      "error": "Unauthorized access to these competitors"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/share-of-voice/cumulative": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Cumulative Share of Voice",
        "description": "Returns aggregated share of voice percentages across the specified date range. Shows what percentage of AI responses mention your brand versus competitors. Each entry also includes `relative_mention_rate`: the entry's mentions as a percentage of responses that mention at least one tracked brand.",
        "operationId": "getCumulativeSOV",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SOVRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with share of voice data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CumulativeSOVEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "name": "Acme Corp",
                      "value": 33.3,
                      "relative_mention_rate": 40,
                      "absolute_value": 150,
                      "is_self": true
                    },
                    {
                      "name": "Competitor Inc",
                      "value": 26.7,
                      "relative_mention_rate": 32,
                      "absolute_value": 120,
                      "is_self": false
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/share-of-voice/time-series": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Share of Voice Over Time",
        "description": "Returns daily share of voice breakdown over the specified date range. Each entry contains the date and SOV percentages for your brand and competitors, plus each company's `relative_mention_rate`: its mentions as a percentage of that day's responses that mention at least one tracked brand.",
        "operationId": "getTimeSeriesSOV",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SOVRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with time series data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TimeSeriesSOVEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "date": "2024-06-15",
                      "Acme Corp": {
                        "value": 33.3,
                        "relative_mention_rate": 40,
                        "is_self": true
                      },
                      "Competitor Inc": {
                        "value": 26.7,
                        "relative_mention_rate": 32,
                        "is_self": false
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/position/cumulative": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Cumulative Position",
        "description": "Returns average position/ranking across the specified date range. Shows where your brand and competitors typically appear in AI responses.",
        "operationId": "getCumulativePosition",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PositionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with position data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/CumulativePositionEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": {
                    "Acme Corp": {
                      "avg_position": 2.5,
                      "is_self": true
                    },
                    "Competitor Inc": {
                      "avg_position": 3.2,
                      "is_self": false
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/position/time-series": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Position Over Time",
        "description": "Returns daily position/ranking breakdown over the specified date range. Each entry contains position metrics for your brand and competitors.",
        "operationId": "getTimeSeriesPosition",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PositionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with time series data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TimeSeriesPositionEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "Acme Corp": {
                        "percentile_ranking": 85.5,
                        "avg_position": 2.5,
                        "is_self": true
                      },
                      "Competitor Inc": {
                        "percentile_ranking": 72.3,
                        "avg_position": 3.2,
                        "is_self": false
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/mention-rate/cumulative": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Cumulative Mention Rate",
        "description": "Returns mention rate percentages across the specified date range. `mention_rate` is absolute (the percentage of all AI responses that mention the brand); `relative_mention_rate` is the percentage of responses mentioning at least one tracked brand.",
        "operationId": "getCumulativeMentionRate",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MentionRateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with mention rate data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/CumulativeMentionRateEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": {
                    "Acme Corp": {
                      "mention_rate": 45.5,
                      "relative_mention_rate": 61.1,
                      "is_self": true
                    },
                    "Competitor Inc": {
                      "mention_rate": 32.1,
                      "relative_mention_rate": 43.2,
                      "is_self": false
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/mention-rate/time-series": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Mention Rate Over Time",
        "description": "Returns daily mention rate breakdown over the specified date range. Each entry contains the date and, per brand/competitor, the absolute `mention_rate` (share of all responses that day) and `relative_mention_rate` (share of that day's responses mentioning at least one tracked brand).",
        "operationId": "getTimeSeriesMentionRate",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MentionRateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with time series data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TimeSeriesMentionRateEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "date": "2024-06-15",
                      "metrics": {
                        "Acme Corp": {
                          "mention_rate": 45.5,
                          "relative_mention_rate": 61.1,
                          "is_self": true
                        },
                        "Competitor Inc": {
                          "mention_rate": 32.1,
                          "relative_mention_rate": 43.2,
                          "is_self": false
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/citation-rate/cumulative": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Cumulative Citation Rate",
        "description": "Returns citation rate percentages across the specified date range. `citation_rate` is absolute (the percentage of all AI responses that cite the brand as a source); `relative_citation_rate` is the percentage of responses citing your brand or at least one tracked competitor.",
        "operationId": "getCumulativeCitationRate",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CitationRateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with citation rate data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/CumulativeCitationRateEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": {
                    "Acme Corp": {
                      "citation_rate": 28.5,
                      "relative_citation_rate": 52.3,
                      "is_self": true
                    },
                    "Competitor Inc": {
                      "citation_rate": 15.2,
                      "relative_citation_rate": 27.9,
                      "is_self": false
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/citation-rate/time-series": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Citation Rate Over Time",
        "description": "Returns daily citation rate breakdown over the specified date range. Each entry contains the date and, per brand/competitor, the absolute `citation_rate` (share of all responses that day) and `relative_citation_rate` (share of that day's responses citing your brand or at least one tracked competitor).",
        "operationId": "getTimeSeriesCitationRate",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CitationRateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with time series data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TimeSeriesCitationRateEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "date": "2024-06-15",
                      "metrics": {
                        "Acme Corp": {
                          "citation_rate": 28.5,
                          "relative_citation_rate": 52.3,
                          "is_self": true
                        },
                        "Competitor Inc": {
                          "citation_rate": 15.2,
                          "relative_citation_rate": 27.9,
                          "is_self": false
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_filters": {
                    "value": {
                      "error": "filters: Required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/shopping": {
      "post": {
        "tags": ["Metrics"],
        "summary": "Shopping Metrics",
        "description": "Returns the Shopping Insights dashboard for a website over a date range: how often the brand's products appear in AI shopping answers (product carousels) versus competitors, average position and price, the top own and competitor products, the competitor leaderboard, retailer breakdown, rank distribution, price comparison, and a daily appearances trend. One call returns every block the in-app Shopping page renders. `models` accepts `chatgpt`, `ai_mode`, `gemini`, `perplexity` and `copilot`. Requires a paid plan.",
        "operationId": "getShoppingMetrics",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShoppingMetricsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with shopping metrics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ShoppingMetricsData"
                    }
                  }
                },
                "example": {
                  "data": {
                    "summary": {
                      "total_shopping_responses": 50,
                      "responses_with_own_products": 20,
                      "appearance_rate": 40,
                      "total_products": 150,
                      "own_products": 40,
                      "competitor_products": 110,
                      "avg_own_position": 2.5,
                      "avg_competitor_position": 4.2
                    },
                    "offer_summary": {
                      "total_offers": 200,
                      "products_with_offers": 80,
                      "competitor_offers": 60,
                      "currency": "USD",
                      "avg_price": 149.99
                    },
                    "top_own_products": [
                      {
                        "title": "Acme Trail Runner 3",
                        "merchant": "Amazon",
                        "appearances": 25,
                        "avg_position": 1.5,
                        "avg_rating": 4.5,
                        "image_url": "https://example.com/trail-runner.jpg",
                        "product_url": "https://example.com/products/trail-runner-3"
                      }
                    ],
                    "top_competitor_products": [
                      {
                        "title": "Rival Speed 2",
                        "merchant": "Walmart",
                        "appearances": 18,
                        "avg_position": 2.2,
                        "avg_rating": 4.1,
                        "image_url": null,
                        "product_url": "https://rival.example/speed-2",
                        "competitor_id": "123e4567-e89b-12d3-a456-426614174222"
                      }
                    ],
                    "competitor_breakdown": [
                      {
                        "competitor_id": "123e4567-e89b-12d3-a456-426614174222",
                        "competitor_name": "Rival Runners",
                        "product_count": 30,
                        "avg_position": 3.5,
                        "avg_rating": 4.2,
                        "response_count": 15
                      }
                    ],
                    "merchant_breakdown": [
                      {
                        "merchant": "Amazon",
                        "own_count": 15,
                        "competitor_count": 35,
                        "own_avg_position": 2.8,
                        "competitor_avg_position": 3.6,
                        "own_response_count": 12,
                        "competitor_response_count": 22
                      }
                    ],
                    "position_distribution": [
                      {
                        "position": 1,
                        "count": 40,
                        "own_count": 12,
                        "competitor_count": 28
                      },
                      {
                        "position": 2,
                        "count": 38,
                        "own_count": 10,
                        "competitor_count": 28
                      }
                    ],
                    "price_comparison": [
                      {
                        "category": "own",
                        "currency": "USD",
                        "avg_price": 149.99,
                        "min_price": 89,
                        "max_price": 219,
                        "product_count": 80
                      },
                      {
                        "category": "competitor",
                        "currency": "USD",
                        "avg_price": 132.5,
                        "min_price": 59,
                        "max_price": 249,
                        "product_count": 60
                      }
                    ],
                    "trend": [
                      {
                        "date": "2026-08-01",
                        "total_products": 5,
                        "own_products": 2,
                        "competitor_products": 3,
                        "total_responses": 4,
                        "responses_with_own": 2
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id: Required"
                    }
                  },
                  "missing_start_date": {
                    "value": {
                      "error": "filters.start_date: Invalid input: expected string, received undefined"
                    }
                  },
                  "unsupported_filter": {
                    "value": {
                      "error": "filters: Unrecognized key: \"prompt_ids\""
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website, a competitor id belongs to another website, or the organization is on the Free plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "competitors": {
                    "value": {
                      "error": "Unauthorized access to these competitors"
                    }
                  },
                  "free_plan": {
                    "value": {
                      "error": "Shopping requires a paid plan"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Website not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/credits/website": {
      "get": {
        "tags": ["Billing"],
        "summary": "Get Website Credits",
        "description": "Returns the current credit balance for a specific website.",
        "operationId": "getWebsiteCredits",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve credits for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with credit balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditsResponse"
                },
                "example": {
                  "credits": {
                    "total": 700,
                    "monthly": {
                      "balance": 700,
                      "next_reset_at": 1772227690021
                    },
                    "one_off": {
                      "balance": 0
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "website_id is required"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to fetch credits"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/credits/organization": {
      "get": {
        "tags": ["Billing"],
        "summary": "Get Organization Credits",
        "description": "Returns the current credit balance for your organization.",
        "operationId": "getOrganizationCredits",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with credit balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditsResponse"
                },
                "example": {
                  "credits": {
                    "total": 5000,
                    "monthly": {
                      "balance": 5000,
                      "next_reset_at": 1772227690021
                    },
                    "one_off": {
                      "balance": 0
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to fetch credits"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/credits/group": {
      "get": {
        "tags": ["Billing"],
        "summary": "Get Group Credits",
        "description": "Returns the current credit balance for a specific group. Requires a global API key.",
        "operationId": "getGroupCredits",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "The ID of the group to retrieve credits for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with credit balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditsResponse"
                },
                "example": {
                  "credits": {
                    "total": 500,
                    "monthly": {
                      "balance": 300,
                      "next_reset_at": 1772227690021
                    },
                    "one_off": {
                      "balance": 200
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "group_id is required"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Group not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Group not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to fetch credits"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invites": {
      "post": {
        "tags": ["Team Management"],
        "summary": "Create Invite",
        "description": "Invites a user to your organization, a specific website, or a group. Use `invite_method: \"direct\"` to add the user immediately without sending any email \u2014 if the email has no existing account, a new user account is created automatically. Use `invite_method: \"email\"` to create a pending invite and send an invitation email that the recipient must accept. Group invites require a global API key. Website invitations require an active website in your key's organization; deleted websites return HTTP 404 before any membership or invitation is created. A website invite with a website-scoped key also requires the key's creator to be an Admin of that website. A direct invite cannot create a new account with an email domain for Cuba, Iran, North Korea, Russia, Belarus, or a regional domain for Crimea (including Sevastopol), Donetsk, or Luhansk; it returns HTTP 400 with an `error` message. General `.ua` domains remain allowed. Existing accounts can still be invited. After SCIM deprovisioning, a new direct organization invitation or acceptance of a new organization invitation explicitly restores organization access. Website and group invitations grant only their requested scope; automatic organization joins remain blocked. Concurrent requests for the same email and target create at most one pending invitation. A duplicate returns HTTP 409 with the same error as a sequential duplicate. Concurrent direct invites reuse the existing account and return HTTP 409 if the membership already exists.",
        "operationId": "createInvite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInviteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User added or invitation sent successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InviteResponse"
                },
                "examples": {
                  "direct_org": {
                    "summary": "User added to organization",
                    "value": {
                      "success": true,
                      "message": "User added to organization",
                      "user_id": "abc12345-e89b-12d3-a456-426614174000"
                    }
                  },
                  "direct_website": {
                    "summary": "User added to website",
                    "value": {
                      "success": true,
                      "message": "User added to website",
                      "user_id": "abc12345-e89b-12d3-a456-426614174000"
                    }
                  },
                  "direct_group": {
                    "summary": "User added to group",
                    "value": {
                      "success": true,
                      "message": "User added to group",
                      "user_id": "abc12345-e89b-12d3-a456-426614174000"
                    }
                  },
                  "email_invite": {
                    "summary": "Email invitation sent",
                    "value": {
                      "success": true,
                      "invite_id": "123e4567-e89b-12d3-a456-426614174000",
                      "message": "Invitation sent"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters or email send failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_json": {
                    "value": {
                      "error": "Invalid JSON body"
                    }
                  },
                  "validation_error": {
                    "value": {
                      "error": "website_id is required when type is 'website'"
                    }
                  },
                  "email_failed": {
                    "value": {
                      "error": "Failed to send invitation email"
                    }
                  },
                  "invalid_email": {
                    "value": {
                      "error": "Email address appears to be invalid or non-existent"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Group invites require a global API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "website_not_found": {
                    "summary": "Website not found",
                    "value": {
                      "error": "Website not found or does not belong to this organization"
                    }
                  },
                  "group_not_found": {
                    "summary": "Group not found",
                    "value": {
                      "error": "Group not found or does not belong to this organization"
                    }
                  },
                  "org_not_found": {
                    "summary": "Organization not found",
                    "value": {
                      "error": "Organization not found"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - User already exists or invite pending",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "already_org_member": {
                    "value": {
                      "error": "User is already a member of this organization"
                    }
                  },
                  "already_website_member": {
                    "value": {
                      "error": "User is already a member of this website"
                    }
                  },
                  "already_group_member": {
                    "value": {
                      "error": "User is already a member of this group"
                    }
                  },
                  "org_member_has_website_access": {
                    "value": {
                      "error": "User is already an organization member and has access to all websites"
                    }
                  },
                  "org_member_has_group_access": {
                    "value": {
                      "error": "User is already an organization member and has access to all groups"
                    }
                  },
                  "pending_invite": {
                    "value": {
                      "error": "A pending invite already exists for this email"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invites/bulk": {
      "post": {
        "tags": ["Team Management"],
        "summary": "Bulk Invite to Websites or Groups",
        "description": "Invites a user to multiple websites OR multiple groups in a single request. Provide exactly one of `website_ids` or `group_ids` \u2014 the two are mutually exclusive. All website IDs must identify active websites in your key's organization; a request containing a deleted website returns HTTP 404 before any invitations or memberships are created. After these checks, each target is processed independently, so some may succeed while others fail (e.g., if the user is already a member). In 'email' mode a single consolidated invitation email is sent. Group invites require a global API key. Website invites with a website-scoped key also require the key's creator to be an Admin of every listed website. Direct invites cannot create new accounts with email domains for Cuba, Iran, North Korea, Russia, Belarus, or regional domains for Crimea (including Sevastopol), Donetsk, or Luhansk. The response remains HTTP 201 with `success: false` and an `error` for each target in `results`. General `.ua` domains remain allowed. Existing accounts can still be invited. Concurrent requests, including requests to the single-invite endpoint, create at most one pending invitation per email and target. Duplicate targets retain HTTP 201 with success: false and the existing duplicate error in results. Concurrent direct invites reuse the existing account; an existing membership is reported as a per-target duplicate.",
        "operationId": "createBulkInvite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkInviteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Bulk invite processed. Check individual results for per-target outcomes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkInviteResponse"
                },
                "examples": {
                  "websites": {
                    "summary": "Bulk website invites",
                    "value": {
                      "success": true,
                      "results": [
                        {
                          "website_id": "123e4567-e89b-12d3-a456-426614174000",
                          "success": true,
                          "message": "User added to website",
                          "user_id": "abc12345-e89b-12d3-a456-426614174000"
                        },
                        {
                          "website_id": "987e6543-e21b-12d3-a456-426614174000",
                          "success": false,
                          "error": "User is already a member of this website"
                        }
                      ]
                    }
                  },
                  "groups": {
                    "summary": "Bulk group invites",
                    "value": {
                      "success": true,
                      "results": [
                        {
                          "group_id": "456e7890-e89b-12d3-a456-426614174000",
                          "success": true,
                          "message": "User added to group",
                          "user_id": "abc12345-e89b-12d3-a456-426614174000"
                        },
                        {
                          "group_id": "789e0123-e89b-12d3-a456-426614174000",
                          "success": false,
                          "error": "User is already a member of this group"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_json": {
                    "value": {
                      "error": "Invalid JSON body"
                    }
                  },
                  "missing_or_both_targets": {
                    "summary": "Neither or both of website_ids/group_ids provided",
                    "value": {
                      "error": "Exactly one of website_ids or group_ids must be provided (not both)"
                    }
                  },
                  "too_many_websites": {
                    "summary": "More than 50 website_ids",
                    "value": {
                      "error": "website_ids must contain at most 50"
                    }
                  },
                  "too_many_groups": {
                    "summary": "More than 50 group_ids",
                    "value": {
                      "error": "group_ids must contain at most 50"
                    }
                  },
                  "invalid_email": {
                    "value": {
                      "error": "Invalid email"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Group invites require a global API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "One or more targets not found or do not belong to this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "websites_not_found": {
                    "value": {
                      "error": "Websites not found or do not belong to this organization: 123e4567-e89b-12d3-a456-426614174000"
                    }
                  },
                  "groups_not_found": {
                    "value": {
                      "error": "Groups not found or do not belong to this organization: 456e7890-e89b-12d3-a456-426614174000"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/subscriptions/website": {
      "get": {
        "tags": ["Billing"],
        "summary": "Get Website Subscription",
        "description": "Returns the subscription products for a specific active website in your API key's organization, including their status and billing dates. Website-scoped keys must also include the website in their allowlist. Deleted websites return HTTP 403 even if their IDs remain in the key's allowlist.",
        "operationId": "getWebsiteSubscription",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve subscription information for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with subscription products",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "products": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SubscriptionProduct"
                      }
                    }
                  },
                  "required": ["products"]
                },
                "example": {
                  "products": [
                    {
                      "id": "pro_monthly",
                      "name": "Pro Plan",
                      "status": "active",
                      "canceled_at": null,
                      "cancel_at": null,
                      "started_at": 1704067200000,
                      "ended_at": null
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "website_id is required"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to fetch subscription"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/subscriptions/cancel": {
      "post": {
        "tags": ["Billing"],
        "summary": "Cancel Subscription",
        "description": "Cancels a subscription for a specific website. The subscription will remain active until the end of the current billing period.",
        "operationId": "cancelSubscription",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelSubscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription cancelled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Whether the cancellation was successful"
                    }
                  },
                  "required": ["success"]
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "missing_product_id": {
                    "value": {
                      "error": "product_id is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to cancel subscription"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/groups": {
      "get": {
        "tags": ["Groups"],
        "summary": "List Groups",
        "description": "Returns all groups for your organization, including associated websites. Requires a global API key. **Partner integrations** may pass `external_id` as a query parameter to find the Athena group mapped to a partner-supplied identifier. Partner responses additionally include `externalId` on each group and on every website object inside `websites` (`null` when no mapping exists), so sites can be matched by your own identifier instead of by URL.",
        "operationId": "listGroups",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "**Partner-only.** Filter results to the group mapped to this partner-supplied identifier. Accepted only when authenticating with a partner API key \u2014 direct customers that pass this parameter receive `403 Forbidden`. Exact match, scoped to your organization; unmapped IDs return an empty array.",
            "example": "acct_9e4c1b8d"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of groups. Partner responses include an `externalId` field on each item (string or `null`); direct-customer responses omit the field entirely.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "groups": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Group"
                      }
                    }
                  },
                  "required": ["groups"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Requires a global API key, or (when using the `external_id` filter) a partner API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "global_required": {
                    "summary": "Global API key required",
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "partner_required": {
                    "summary": "Partner API key required for external_id filter",
                    "value": {
                      "error": "Forbidden: partner API key required"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Groups"],
        "summary": "Create Group",
        "description": "Creates a new group with associated websites. Requires a global API key. **Partner integrations** may include an `external_id` to map their own identifier onto the new Athena group.",
        "operationId": "createGroup",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateGroupRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Group created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "group": {
                      "$ref": "#/components/schemas/CreatedGroup"
                    },
                    "billingEntityCreated": {
                      "type": "boolean",
                      "description": "Present only when billing_enabled was requested: whether the billing entity exists after provisioning. When false, entity creation failed even after a retry, and setting group credits fails with a 400 until billing is repaired via PATCH /api/v1/groups/{group_id} with billing_enabled: true."
                    }
                  },
                  "required": ["group"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error or invalid website IDs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_json": {
                    "value": {
                      "error": "Invalid JSON body"
                    }
                  },
                  "invalid_website_ids": {
                    "value": {
                      "error": "Website IDs not found in organization: 123e4567-e89b-12d3-a456-426614174000"
                    }
                  },
                  "missing_name": {
                    "value": {
                      "error": "Group name is required"
                    }
                  },
                  "missing_websites": {
                    "value": {
                      "error": "At least one website_id is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Requires a global API key, or (partner-only field) the key lacks partner identity for an `external_id`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "global_required": {
                    "summary": "Global API key required",
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "partner_required": {
                    "summary": "Partner API key required for external_id",
                    "value": {
                      "error": "Forbidden: partner API key required"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - (partners only) the supplied `external_id` is already mapped to another group.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalIdConflictError"
                },
                "examples": {
                  "external_id_conflict": {
                    "summary": "Partner external_id already mapped",
                    "value": {
                      "error": "external_id_conflict",
                      "message": "external_id acct_9e4c1b8d is already mapped to a group",
                      "existing": {
                        "id": "123e4567-e89b-12d3-a456-426614174000",
                        "externalId": "acct_9e4c1b8d"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/groups/{group_id}": {
      "parameters": [
        {
          "name": "group_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the group",
          "example": "123e4567-e89b-12d3-a456-426614174000"
        }
      ],
      "get": {
        "tags": ["Groups"],
        "summary": "Get Group",
        "description": "Returns a single group by ID, including associated websites. Requires a global API key. **Partner integrations** additionally receive an `externalId` field populated from the partner mapping (if any), and every website object inside `websites` carries its own `externalId` (`null` when that website has no mapping), so sites can be matched by your own identifier instead of by URL.",
        "operationId": "getGroup",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the group. Partner responses include an `externalId` field (string or `null`); direct-customer responses omit the field entirely.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "group": {
                      "$ref": "#/components/schemas/Group"
                    }
                  },
                  "required": ["group"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid group ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invalid group ID format"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Group does not exist or does not belong to your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Group not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["Groups"],
        "summary": "Update Group",
        "description": "Updates a group's name, adds websites, removes websites, and/or (partners only) sets or clears the `external_id` mapping. At least one field must be provided. Requires a global API key. **Partner integrations** may pass `external_id` as a non-empty string to set/replace the mapping, or as `null` to clear it. The partner response includes `externalId` on the group and on every website object inside `websites` (`null` when no mapping exists).",
        "operationId": "updateGroup",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateGroupRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Group updated successfully. Partner responses include an `externalId` field (string or `null`); direct-customer responses omit the field entirely.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "group": {
                      "$ref": "#/components/schemas/Group"
                    }
                  },
                  "required": ["group"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error or invalid website IDs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_fields": {
                    "value": {
                      "error": "At least one of 'name', 'add_website_ids', 'remove_website_ids', 'external_id', or 'billing_enabled' is required"
                    }
                  },
                  "invalid_website_ids": {
                    "value": {
                      "error": "Website IDs not found in organization: 123e4567-e89b-12d3-a456-426614174000"
                    }
                  },
                  "invalid_group_id": {
                    "value": {
                      "error": "Invalid group ID format"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Requires a global API key, or (partner-only field) the key lacks partner identity for an `external_id`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "global_required": {
                    "summary": "Global API key required",
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "partner_required": {
                    "summary": "Partner API key required for external_id",
                    "value": {
                      "error": "Forbidden: partner API key required"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Group does not exist or does not belong to your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Group not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - (partners only) the supplied `external_id` is already mapped to another group.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalIdConflictError"
                },
                "examples": {
                  "external_id_conflict": {
                    "summary": "Partner external_id already mapped",
                    "value": {
                      "error": "external_id_conflict",
                      "message": "external_id acct_9e4c1b8d is already mapped to a group",
                      "existing": {
                        "id": "123e4567-e89b-12d3-a456-426614174000",
                        "externalId": "acct_9e4c1b8d"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Upstream billing provider failed to provision the billing entity. Only returned when `billing_enabled: true` is in the request body. No database changes were committed \u2014 the request can be retried cleanly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to provision billing entity"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/groups/{group_id}/members": {
      "parameters": [
        {
          "name": "group_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the group"
        },
        {
          "name": "access_type",
          "in": "query",
          "required": false,
          "schema": {
            "type": "string",
            "enum": ["organization", "group"]
          },
          "description": "Optional filter. Pass `group` to get only users explicitly added to this group's `group_members` table \u2014 a user who also has org access is still returned (raw rows, no dedup). Pass `organization` to get only the parent org's members. Omit the parameter to get the merged view with org-member precedence."
        }
      ],
      "get": {
        "tags": ["Team Management"],
        "summary": "List Group Members",
        "description": "Returns all users with access to a group. By default, the response merges **organization members** (implicit access to every group in the org) and users with explicit **group-member rows**, tagging each entry with an `access_type` field (`organization` or `group`). If a user has both an org membership and a `group_members` row, the merged view returns them once as `access_type: \"organization\"` (org precedence).\n\nUse the `access_type` query parameter to filter: `?access_type=group` returns the raw `group_members` rows (including users who also have org access), and `?access_type=organization` returns only the org's implicit members. Requires a global API key.",
        "operationId": "listGroupMembers",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the list of members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/GroupMemberListItem"
                      }
                    }
                  },
                  "required": ["members"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid group ID format or invalid access_type value",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_group_id": {
                    "summary": "Invalid group ID format",
                    "value": {
                      "error": "Invalid group ID format"
                    }
                  },
                  "invalid_access_type": {
                    "summary": "Invalid access_type value",
                    "value": {
                      "error": "access_type must be 'organization' or 'group'"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Group does not exist or does not belong to your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Group not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/groups/{group_id}/members/{user_id}": {
      "parameters": [
        {
          "name": "group_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the group"
        },
        {
          "name": "user_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the target user"
        }
      ],
      "patch": {
        "tags": ["Team Management"],
        "summary": "Update Group Member Role",
        "description": "Updates the role of a user who was explicitly added to a group (a `group_members` row, shown as `access_type: \"group\"` by `GET /api/v1/groups/{group_id}/members`). Accepts either the coarse `role` (admin/viewer) or a `role_id`: a system role or one of your organization's custom roles (see `GET /api/v1/roles`). Provide exactly one. Requires a global API key.\n\nOrganization members are out of scope: their access to every group in the org comes from their organization role, so a group-level write would not change what they can do. Targeting one returns `409`; use `PATCH /api/v1/organizations/members/{user_id}` instead. The API key's own user cannot be modified. There is no last-admin restriction at group scope: a group's only admin can be demoted, since organization admins retain admin access to every group in the organization.\n\n**Roles other than `admin` and `viewer` are honored for access but are not yet rendered in the dashboard.** A `role_id` such as Editor or Billing Manager grants that role's real permissions on every website in the group, but the dashboard's group member list currently collapses any non-admin role to \"Viewer\". Prefer `admin` / `viewer` at group scope when a customer administrator also needs to see the assigned role.",
        "operationId": "updateGroupMemberRole",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateGroupMemberRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Member role updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "member": {
                      "type": "object",
                      "required": ["user_id", "group_id", "role", "role_id"],
                      "properties": {
                        "user_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Unique identifier of the user"
                        },
                        "group_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Unique identifier of the group"
                        },
                        "role": {
                          "type": "string",
                          "description": "Slug of the assigned role (e.g. 'admin', 'viewer', or a custom role's slug). Matches the `role` field returned by `GET /api/v1/groups/{group_id}/members`.",
                          "example": "viewer"
                        },
                        "role_id": {
                          "type": "string",
                          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                          "description": "ID of the assigned role (a system role ID or a custom role ID)"
                        }
                      }
                    }
                  },
                  "required": ["success", "member"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid body or path parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Not a global key, or self-modification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_global": {
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "self_modification": {
                    "value": {
                      "error": "You cannot modify your own membership"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Group does not exist in your organization, the user has no explicit group membership, or the requested `role_id` does not exist in your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "group_not_found": {
                    "value": {
                      "error": "Group not found"
                    }
                  },
                  "member_not_found": {
                    "value": {
                      "error": "Group member not found"
                    }
                  },
                  "role_not_found": {
                    "value": {
                      "error": "Role not found"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - The user's access to this group comes from their organization membership, so there is no group-level role to change. Changing their organization role instead applies across every group and website in the organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "User is an organization member: their access to this group comes from their organization role, so there is no group-level role to change. Changing it with PATCH /api/v1/organizations/members/{user_id} would apply across every group and website in the organization, not only this group."
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Team Management"],
        "summary": "Remove Group Member Access",
        "description": "Removes a user's direct group membership and their explicit website memberships for websites currently in the group. Both sets of rows are removed atomically. The request is idempotent: a retry, or a well-formed user ID with no matching membership rows, returns `200` with `group_membership_removed: false` and `website_memberships_removed: 0`.\n\nOrganization membership, membership in other groups, and website membership outside this group are preserved. If another group grants access to one of the same websites, that effective access remains through the other group even though the user's explicit website membership row is removed. Organization members return `409` because their organization-derived access would remain. Requires a global API key, and the API key's own user cannot be removed. The endpoint accepts no request body.",
        "operationId": "removeGroupMemberAccess",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Group-scoped membership removal completed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "group_membership_removed",
                    "website_memberships_removed"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [true],
                      "example": true
                    },
                    "group_membership_removed": {
                      "type": "boolean",
                      "description": "Whether a direct group membership row was removed",
                      "example": true
                    },
                    "website_memberships_removed": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "Number of explicit website membership rows removed for websites currently in the group",
                      "example": 3
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid group or user ID",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Not a global API key, or attempted self-removal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_global": {
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "self_removal": {
                    "value": {
                      "error": "You cannot remove your own membership"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Group does not exist in your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Group not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - The target is an organization member whose organization-derived access would remain",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "User is an organization member: removing group-scoped memberships would not revoke their organization-derived access"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invites/org/{invite_id}": {
      "parameters": [
        {
          "name": "invite_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the organization invite"
        }
      ],
      "delete": {
        "tags": ["Team Management"],
        "summary": "Revoke Organization Invite",
        "description": "Soft-revokes a **pending** organization invite by setting its status to `revoked`. The invite row is preserved for audit purposes. Returns 409 if the invite is in any other state (already accepted, declined, expired, or revoked), since revoking an accepted invite would leave a misleading audit trail while the underlying membership row remains untouched. To remove an already-accepted member, use `DELETE /api/v1/organizations/members/{user_id}` instead. Requires a global API key.",
        "operationId": "revokeOrgInvite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Invite revoked successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Invite revoked"
                    },
                    "invite_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": ["success", "message", "invite_id"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid invite ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invalid invite ID format"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Invite does not exist or does not belong to your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invite not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Invite is not in pending state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invite is not pending (current status: accepted)"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invites/website/{invite_id}": {
      "parameters": [
        {
          "name": "invite_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the website invite"
        }
      ],
      "delete": {
        "tags": ["Team Management"],
        "summary": "Revoke Website Invite",
        "description": "Soft-revokes a **pending** website invite by setting its status to `revoked`. The website must be active and belong to your key's organization; an invite on a deleted website returns HTTP 404 and is unchanged. Accepts a global API key, or a website-scoped key if the invite's target website is included in the key's allowlist and the key's creator is an Admin of that website. Returns 409 if the invite is in any other state. To remove an already-accepted member, use `DELETE /api/v1/websites/{website_id}/members/{user_id}` instead.",
        "operationId": "revokeWebsiteInvite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Invite revoked successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Invite revoked"
                    },
                    "invite_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": ["success", "message", "invite_id"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid invite ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - API key does not have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Invite does not exist or does not belong to your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invite not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Invite is not in pending state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invite is not pending (current status: accepted)"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/websites/{website_id}": {
      "parameters": [
        {
          "name": "website_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the website",
          "example": "123e4567-e89b-12d3-a456-426614174000"
        }
      ],
      "patch": {
        "tags": ["Basics"],
        "summary": "Update Website",
        "description": "Sets, replaces, or clears the partner `external_id` mapped to a website. **Partner integrations only:** pass `external_id` as a non-empty string to set or replace the mapping, or as `null` to clear it. Requires a global API key. Works on deleted websites too, because deleting a website does not release its `external_id`. An `external_id` already mapped to another website in your organization returns `409` naming the current holder; to move an id from one website to another, clear it on the current holder first, then set it on the new one.",
        "operationId": "updateWebsite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebsiteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Mapping updated. `externalId` is always present on this response: the new value, or `null` after a clear. Like the `external_id` lookup responses, and unlike the `GET /api/v1/websites` listing, this endpoint does not return `baseCountry`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["website"],
                  "properties": {
                    "website": {
                      "type": "object",
                      "required": [
                        "id",
                        "websiteName",
                        "websiteUrl",
                        "onboardingStep",
                        "externalId"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Unique identifier for the website",
                          "example": "123e4567-e89b-12d3-a456-426614174000"
                        },
                        "websiteName": {
                          "type": "string",
                          "description": "Display name of the website",
                          "example": "My Awesome Blog"
                        },
                        "websiteUrl": {
                          "type": "string",
                          "description": "The domain of the website (without protocol)",
                          "example": "example.com"
                        },
                        "onboardingStep": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Current onboarding step for the website. Null indicates onboarding is complete.",
                          "example": null
                        },
                        "externalId": {
                          "type": "string",
                          "nullable": true,
                          "description": "The partner-supplied identifier now mapped to this website, or `null` when the request cleared the mapping.",
                          "example": "ws_a7f3b2c9"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Validation error or invalid website ID",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_external_id": {
                    "summary": "external_id was not sent",
                    "value": {
                      "error": "'external_id' is required"
                    }
                  },
                  "invalid_website_id": {
                    "summary": "Website id is not a UUID",
                    "value": {
                      "error": "Invalid website ID format"
                    }
                  },
                  "invalid_json": {
                    "summary": "Body is not valid JSON",
                    "value": {
                      "error": "Invalid JSON body"
                    }
                  },
                  "unrecognized_field": {
                    "summary": "Unknown keys are rejected rather than ignored",
                    "value": {
                      "error": "Unrecognized key: \"externalId\""
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Requires a global API key, and the key must belong to an organization flagged as a partner.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "global_required": {
                    "summary": "Global API key required",
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "partner_required": {
                    "summary": "Partner API key required for external_id",
                    "value": {
                      "error": "Forbidden: partner API key required"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website does not exist or does not belong to your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - the supplied `external_id` is already mapped to another website in your organization. Clear it on that website first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalIdConflictError"
                },
                "examples": {
                  "external_id_conflict": {
                    "summary": "Partner external_id already mapped",
                    "value": {
                      "error": "external_id_conflict",
                      "message": "external_id ws_a7f3b2c9 is already mapped to a website",
                      "existing": {
                        "id": "123e4567-e89b-12d3-a456-426614174000",
                        "externalId": "ws_a7f3b2c9"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/websites/{website_id}/delete": {
      "parameters": [
        {
          "name": "website_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the website"
        }
      ],
      "post": {
        "tags": ["Basics"],
        "summary": "Delete Website",
        "description": "Deletes a website. Removes it from your organization and stops all associated processing. Requires a global API key. Idempotent: re-calling on an already deleted website returns 200. This action is reversible \u2014 call `POST /api/v1/websites/{website_id}/restore` to reactivate a deleted website.",
        "operationId": "deleteWebsite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Website deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Website deleted"
                    }
                  },
                  "required": ["success", "message"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid UUID in path",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invalid website ID format"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - A global API key is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website does not exist in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - The website holds an entity-scoped subscription. Deleting it would strand the subscription and its credits on a deleted website, so the plan must be cancelled or moved first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "This website holds your organization's subscription, so deleting it would strand your credits. Cancel the plan on the Billing page in Settings first, or contact support to move it to another website."
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/websites/{website_id}/restore": {
      "parameters": [
        {
          "name": "website_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the website"
        }
      ],
      "post": {
        "tags": ["Basics"],
        "summary": "Restore Website",
        "description": "Restores a previously deleted website, reactivating processing and making it available again. All historical data is preserved. Requires a global API key. Idempotent: re-calling on an already active website returns 200.",
        "operationId": "restoreWebsite",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Website restored successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Website restored"
                    }
                  },
                  "required": ["success", "message"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid UUID in path",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invalid website ID format"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - A global API key is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website does not exist in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/websites/{website_id}/members": {
      "parameters": [
        {
          "name": "website_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the website"
        }
      ],
      "get": {
        "tags": ["Team Management"],
        "summary": "List Website Members",
        "description": "Returns all users with access to a website \u2014 both organization members (implicit access to every website in the org) and users with explicit website-member rows. Each entry includes an `access_type` field (`organization` or `website`) so you can tell them apart. If a user has both an org membership and a stray website-member row, they appear once with `access_type: \"organization\"`. Accepts a global API key, or a website-scoped key if the website is in the key's allowlist. The website must be active and belong to your key's organization; deleted websites return HTTP 403 even if their IDs remain in the allowlist.",
        "operationId": "listWebsiteMembers",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the list of members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebsiteMemberListItem"
                      }
                    }
                  },
                  "required": ["members"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid website ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - API key does not have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/websites/{website_id}/members/{user_id}": {
      "parameters": [
        {
          "name": "website_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the website"
        },
        {
          "name": "user_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the target user"
        }
      ],
      "delete": {
        "tags": ["Team Management"],
        "summary": "Remove Website Member",
        "description": "Removes a user's explicit membership from a website. Accepts a global API key, or a website-scoped key if the website is included in the key's allowlist and the key's creator is an Admin of that website. The website must be active and belong to your key's organization; deleted websites return HTTP 403 even if their IDs remain in the allowlist. Cannot be used to remove the API key's owning user or the organization owner.",
        "operationId": "removeWebsiteMember",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Member removed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "User removed from website"
                    }
                  },
                  "required": ["success", "message"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid UUID in path",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Unauthorized website access, self-modification, or owner modification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "self_modification": {
                    "value": {
                      "error": "You cannot modify your own membership"
                    }
                  },
                  "owner_modification": {
                    "value": {
                      "error": "Cannot modify the organization owner"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website member does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website member not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["Team Management"],
        "summary": "Update Website Member Role",
        "description": "Updates a website member's role. Accepts a global API key, or a website-scoped key if the website is included in the key's allowlist and the key's creator is an Admin of that website. The website must be active and belong to your key's organization; deleted websites return HTTP 403 even if their IDs remain in the allowlist. Cannot be used to modify the API key's owning user or the organization owner.",
        "operationId": "updateWebsiteMemberRole",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMemberRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Member role updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "member": {
                      "$ref": "#/components/schemas/WebsiteMember"
                    }
                  },
                  "required": ["success", "member"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid body or path parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Unauthorized website access, self-modification, or owner modification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website member does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/organizations/members": {
      "get": {
        "tags": ["Team Management"],
        "summary": "List Organization Members",
        "description": "Returns all members of your organization, including user details (email, first/last name) and their organization role. Requires a global API key.",
        "operationId": "listOrgMembers",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the list of members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/OrgMemberListItem"
                      }
                    }
                  },
                  "required": ["members"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/organizations/members/{user_id}": {
      "parameters": [
        {
          "name": "user_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the target user"
        }
      ],
      "delete": {
        "tags": ["Team Management"],
        "summary": "Remove Organization Member",
        "description": "Removes a user from your organization. Also removes explicit website and Market Landscape memberships issued by this organization and revokes its pending Market Landscape invitations for the user, within a single transaction. Access issued by other organizations is preserved. Requires a global API key. Cannot remove the API key's owning user, the organization owner, or the last remaining admin.",
        "operationId": "removeOrgMember",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Member removed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "User removed from organization"
                    },
                    "websites_affected": {
                      "type": "integer",
                      "description": "Number of stray website_members rows that were cleaned up as part of the cascade.",
                      "example": 0
                    }
                  },
                  "required": ["success", "message", "websites_affected"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid user ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Not a global key, self-modification, or owner modification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_global": {
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "self_modification": {
                    "value": {
                      "error": "You cannot modify your own membership"
                    }
                  },
                  "owner_modification": {
                    "value": {
                      "error": "Cannot modify the organization owner"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Organization member does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Organization member not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Cannot remove the last remaining admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Cannot remove the last admin from the organization"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["Team Management"],
        "summary": "Update Organization Member Role",
        "description": "Updates an organization member's role. Accepts either the coarse `role` (admin/viewer) or a `role_id` \u2014 a system role or one of your organization's custom roles (see `GET /api/v1/roles`); provide exactly one. Requires a global API key. Cannot modify the API key's owning user or the organization owner. Cannot demote the last remaining admin.",
        "operationId": "updateOrgMemberRole",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrgMemberRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Member role updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "member": {
                      "type": "object",
                      "required": ["user_id", "org_id", "role", "role_id"],
                      "properties": {
                        "user_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Unique identifier of the user"
                        },
                        "org_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Unique identifier of the organization"
                        },
                        "role": {
                          "type": "string",
                          "description": "Slug of the assigned role (e.g. 'admin', 'viewer', or a custom role's slug)",
                          "example": "admin"
                        },
                        "role_id": {
                          "type": "string",
                          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                          "description": "ID of the assigned role (a system role ID or a custom role ID)"
                        }
                      }
                    }
                  },
                  "required": ["success", "member"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid body or path parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Not a global key, self-modification, or owner modification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Organization member does not exist, or the requested `role_id` does not exist in your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Cannot demote the last remaining admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Cannot demote the last admin of the organization"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/roles": {
      "get": {
        "tags": ["Team Management"],
        "summary": "List Roles",
        "description": "Returns all roles available in your organization: the built-in system roles (Admin, Editor, Viewer, Billing) plus your organization's custom roles, each with its resolved permission matrix. Use a role's `role_id` to assign it via invites or member role updates. Requires a global API key.",
        "operationId": "listRoles",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the list of roles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["roles"],
                  "properties": {
                    "roles": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Role"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Team Management"],
        "summary": "Create Custom Role",
        "description": "Creates a custom role with a per-category permission matrix. Custom roles are available on the Enterprise plan. Every category is at least 'view' \u2014 omitted categories default to 'view'. The role name must be unique in your organization and must not collide with a system role name; the permission matrix must not duplicate an existing role's. Requires a global API key.",
        "operationId": "createRole",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRoleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Role created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "role"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "role": {
                      "$ref": "#/components/schemas/Role"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid role name or permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required, or the organization is not on the Enterprise plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_global": {
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "not_enterprise": {
                    "value": {
                      "error": "Custom roles are available on the Enterprise plan."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Role name already exists or permissions duplicate an existing role's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/roles/{role_id}": {
      "parameters": [
        {
          "name": "role_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
          },
          "description": "The unique identifier of the role (a system role ID or a custom role ID)"
        }
      ],
      "get": {
        "tags": ["Team Management"],
        "summary": "Get Role",
        "description": "Returns a single role \u2014 a system role or one of your organization's custom roles \u2014 with its resolved permission matrix. Requires a global API key.",
        "operationId": "getRole",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the role",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["role"],
                  "properties": {
                    "role": {
                      "$ref": "#/components/schemas/Role"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid role ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Role does not exist in your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Role not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["Team Management"],
        "summary": "Update Custom Role",
        "description": "Updates a custom role's permission matrix. Every category is at least 'view' \u2014 omitted categories default to 'view'. System roles cannot be edited. The new matrix must not duplicate an existing role's. Requires a global API key.",
        "operationId": "updateRole",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Role updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "role"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "role": {
                      "$ref": "#/components/schemas/Role"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid role ID format or permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required, or the role is a system role",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_global": {
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "system_role": {
                    "value": {
                      "error": "System roles can't be edited"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Role does not exist in your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Role not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Permissions duplicate an existing role's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Team Management"],
        "summary": "Delete Custom Role",
        "description": "Deletes a custom role. System roles cannot be deleted, and a role that is still assigned to members or pending invites (or set as a default role) cannot be deleted. Requires a global API key.",
        "operationId": "deleteRole",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Role deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "message"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Role deleted"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid role ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required, or the role is a system role",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_global": {
                    "value": {
                      "error": "Forbidden: global API key required"
                    }
                  },
                  "system_role": {
                    "value": {
                      "error": "System roles can't be deleted"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - Role does not exist in your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Role not found"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Role is still assigned to members or invites, or set as a default role",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "This role is still assigned to members or invites, or set as a default role"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/users/{user_id}/websites": {
      "parameters": [
        {
          "name": "user_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The unique identifier of the target user"
        }
      ],
      "delete": {
        "tags": ["Team Management"],
        "summary": "Remove User From Websites",
        "description": "Batch-removes a user's explicit website memberships within your organization. Pass the website IDs as a comma-separated list in the `website_ids` query parameter (at most 100). Requires a global API key. Idempotent: websites where the user has no explicit membership are reported with status `not_a_member` rather than failing the request, so re-calling is safe. Organization-level access is not affected \u2014 this only removes explicit `website_members` rows.",
        "operationId": "removeUserFromWebsites",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_ids",
            "in": "query",
            "required": true,
            "description": "Comma-separated list of website UUIDs to remove the user from (at most 100).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Per-website removal results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [true]
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "website_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": ["removed", "not_a_member"]
                          }
                        },
                        "required": ["website_id", "status"]
                      }
                    }
                  },
                  "required": ["success", "results"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid user ID or website_ids",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - No AthenaHQ user exists for this user_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "User not found"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - Rate limit exceeded. Retry after a short delay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": ["Team Management"],
        "summary": "List User Websites",
        "description": "Returns the websites that a user has access to within your organization, either via organization membership (implicit access to all websites in the org) or via explicit website membership. Organization membership takes precedence \u2014 if the user is an org member, all non-paused websites in your organization are returned with `access_type: \"organization\"`. Otherwise, only websites the user has an explicit `website_members` row for are returned. Returns `404` if the `user_id` does not match any AthenaHQ user. Returns `200` with an empty `websites` array if the user exists but has no access within your organization (this intentionally does not distinguish \"user is in a different org\" from \"user is in your org but has no access\"). Requires a global API key. **Partner integrations** additionally receive an `external_id` field on each website (`null` when no mapping exists); direct-customer responses omit the field.",
        "operationId": "listUserWebsites",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the list of websites (may be empty)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "websites": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/UserWebsite"
                      }
                    }
                  },
                  "required": ["websites"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid user ID format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - No AthenaHQ user exists for this user_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "User not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/users/by-email": {
      "post": {
        "tags": ["Team Management"],
        "summary": "Look Up User By Email",
        "description": "Resolves a user's `user_id` from their email address, scoped to your organization. The email is sent in the request body (not the URL) so it never lands in request logs or analytics. Returns the user only when they belong to your organization \u2014 either as an organization member (`access_type: \"organization\"`) or as an explicit member of at least one non-paused website in your organization (`access_type: \"website\"`). Any other case, including an email that belongs to a user in a different organization, returns `404` with the same body as a truly unknown email, so the endpoint cannot be used to enumerate accounts across tenants. Requires a global API key. Use the returned `user_id` with the member-management endpoints (e.g. list a user's websites or remove website access) without a discovery round-trip.",
        "operationId": "getUserByEmail",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "Email address to look up. Matched case-insensitively."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "User found within your organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "type": "object",
                      "properties": {
                        "user_id": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "first_name": {
                          "type": "string",
                          "nullable": true
                        },
                        "last_name": {
                          "type": "string",
                          "nullable": true
                        },
                        "access_type": {
                          "type": "string",
                          "enum": ["organization", "website"],
                          "description": "`organization` when the user is a member of your organization (implicit access to all its websites); `website` when the user only has explicit membership on one or more websites in your organization."
                        }
                      },
                      "required": [
                        "user_id",
                        "email",
                        "first_name",
                        "last_name",
                        "access_type"
                      ]
                    }
                  },
                  "required": ["user"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid email format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invalid email format"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Global API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Not found - No matching user in your organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "User not found"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - Rate limit exceeded. Retry after a short delay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/saved-views": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Saved Views",
        "description": "Returns all saved views (filter presets) for a specific website. Each saved view captures a named set of filters that can be reused across the dashboard.",
        "operationId": "getSavedViews",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve saved views for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of saved views",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "saved_views": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SavedView"
                      }
                    }
                  },
                  "required": ["saved_views"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/group-saved-views": {
      "get": {
        "tags": ["Basics"],
        "summary": "Get Group Saved Views",
        "description": "Returns all group-level saved views (filter presets) for the websites in a group. Group saved views capture filter state shared across the group rather than scoped to a single website.",
        "operationId": "getGroupSavedViews",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "ID of the group to retrieve saved views for. Authorization runs against this group's org.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of group saved views",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "group_saved_views": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/GroupSavedView"
                      }
                    }
                  },
                  "required": ["group_saved_views"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - You don't have access to this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-access/check": {
      "post": {
        "tags": ["AI Access"],
        "summary": "Check AI accessibility for a domain",
        "description": "Check robots.txt policy and HTTP responses to crawler user-agent probes from Athena's network. Use result.evidence and per-agent diagnostics; challenges, timeouts and server errors produce unknown observations. Search, retrieval and training are separate. These probes do not verify real crawler access or guarantee indexing or citations. Legacy status and booleans remain for compatibility.\n\nRate limited to 30 requests per minute per organization.",
        "operationId": "checkAIAccess",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "type": "string",
                    "description": "The domain to probe (with or without protocol).",
                    "example": "example.com"
                  }
                },
                "required": ["domain"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful AI access check.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AIAccessCheckResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/content/sheets": {
      "get": {
        "tags": ["Content"],
        "summary": "List Content Hub Sheets",
        "description": "Returns the Content Hub tabs configured for a website. Each tab is either a `sheet` (content pinned via `content.sheet_id`) or a `view` (saved filter layout over the main content pool). Call this first to discover the `sheet_id`s you can pass to `POST /api/v1/content`.",
        "operationId": "listContentSheets",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The website to list sheets for.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the list of sheets, ordered by `position` ascending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sheets": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ContentSheet"
                      }
                    }
                  },
                  "required": ["sheets"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request \u2014 invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 you don't have access to this website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/content": {
      "post": {
        "tags": ["Content"],
        "summary": "List Tracked Content",
        "description": "Returns paginated tracked content with citation, impression, and response metrics joined for the requested date range. Hidden content (`is_hidden = true`) is excluded.\n\nPagination uses `page_size + 1` lookahead \u2014 `pagination.has_more === true` means the next page exists; there is no total-count field.\n\nUse the `sheet_id`, `content_type`, and standard `filters` knobs to scope the result. Pass an unknown `sheet_id` (or one from another website) and the endpoint returns 403.",
        "operationId": "listTrackedContent",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContentListRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with the page of tracked content.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentListResponse"
                },
                "example": {
                  "content": [
                    {
                      "content_id": "11111111-2222-3333-4444-555555555555",
                      "title": "Best CRMs for Startups, Reviewed",
                      "url": "example.com/blog/crm-roundup",
                      "normalized_url": "example.com/blog/crm-roundup",
                      "type": "external",
                      "topic_name": "CRM Software",
                      "sheet_id": "00000000-0000-4000-8000-000000000001",
                      "sheet_name": "3rd-Party Placements",
                      "citations": 42,
                      "citation_percent": 12.5,
                      "estimated_impressions": 18400,
                      "total_responses": 336,
                      "mark_as_done_time": "2024-01-15T00:00:00.000Z",
                      "created_at": "2024-01-10T00:00:00.000Z"
                    }
                  ],
                  "pagination": {
                    "page_num": 0,
                    "page_size": 50,
                    "has_more": true
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request \u2014 invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 you don't have access to this website, or a sub-resource ID (`prompt_ids`, `competitor_ids`, `location_ids`, `persona_ids`, `prompt_tags`, `sheet_id`) belongs to another website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "sheet": {
                    "value": {
                      "error": "Unauthorized access to this sheet"
                    }
                  },
                  "prompts": {
                    "value": {
                      "error": "Unauthorized access to these prompts"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/content/prompts": {
      "post": {
        "tags": ["Content"],
        "summary": "Per-Content Prompt Citation Breakdown",
        "description": "For a single tracked content item, returns every prompt whose AI responses cite the URL \u2014 with citations, citation %, and estimated impressions for the date range.\n\nUse this to drill into a specific URL after `POST /api/v1/content`. Works for both 1st-party (topic-attached) and 3rd-party / Reddit content without topic assignment.\n\nWhen the URL exists but has no normalized form (legacy unnormalized rows) the response is a successful 200 with `prompts: []`. Unknown `content_id` returns 404.",
        "operationId": "getContentPromptBreakdown",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContentPromptBreakdownRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with the list of citing prompts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentPromptBreakdownResponse"
                },
                "example": {
                  "content_id": "11111111-2222-3333-4444-555555555555",
                  "content_url": "example.com/blog/crm-roundup",
                  "content_normalized_url": "example.com/blog/crm-roundup",
                  "prompts": [
                    {
                      "prompt_id": "22222222-3333-4444-5555-666666666666",
                      "prompt": "what are the best CRMs for early-stage startups?",
                      "citation_percent": 33.3,
                      "citations": 5,
                      "estimated_impressions": 1200
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request \u2014 invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 you don't have access to this website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Content not found for this website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Content not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/api-keys": {
      "get": {
        "tags": ["Basics"],
        "summary": "List API Keys",
        "operationId": "listApiKeys",
        "description": "Lists API key metadata for the authenticated key's organization, including each key's creator (ID, current name and email), creation date, scope and revocation status. Requires a global API key; website-scoped keys receive 403. No organization ID is accepted. Secrets and hashes are never returned. Revoked keys are included so you can detect a key created and revoked between polls. Results are ordered by creation date ascending, then ID ascending.\n\nFor new-key alerts, first record a baseline of key IDs. On each poll, pin `until` to now minus one minute, overlap `since` with the previous successful window, and keep both bounds fixed while incrementing `page_num` until `pagination.has_more` is false. Both time bounds are inclusive. Deduplicate alerts by key ID and advance your saved window only after all pages succeed. Filter `is_revoked` locally if you need active keys only.\n\nThis is a current inventory, not a durable audit log or webhook: deleting a creator's account removes their keys, and concurrent deletions can shift pages. Overlapping windows reduce polling gaps but cannot guarantee detection of every creation. The MCP tool `list_api_keys` exposes the same fields and filters to global API keys and organization-admin OAuth connections, subject to MCP permissions.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Include keys created at or after this ISO 8601 timestamp.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "Include keys created at or before this ISO 8601 timestamp. Keep fixed while paging.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "page_num",
            "in": "query",
            "required": false,
            "description": "Zero-based page number.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "description": "Number of keys per page, up to 100.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "API key metadata, including revoked keys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["api_keys", "pagination"],
                  "properties": {
                    "api_keys": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "key_prefix",
                          "created_at",
                          "created_by",
                          "is_global",
                          "website_ids",
                          "is_revoked"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          },
                          "key_prefix": {
                            "type": "string",
                            "description": "Non-secret identifying prefix. Secrets and hashes are never returned."
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "created_by": {
                            "type": "object",
                            "required": ["id", "name", "email"],
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": "string",
                                "nullable": true
                              },
                              "email": {
                                "type": "string"
                              }
                            }
                          },
                          "is_global": {
                            "type": "boolean"
                          },
                          "website_ids": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "description": "Allowed website IDs for a scoped key; empty for a global key."
                          },
                          "is_revoked": {
                            "type": "boolean",
                            "description": "Whether the key has been revoked."
                          }
                        }
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "required": ["page_num", "page_size", "has_more"],
                      "properties": {
                        "page_num": {
                          "type": "integer"
                        },
                        "page_size": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameters or since is after until.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "A global API key is required.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["error"],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/activity": {
      "get": {
        "tags": ["Basics"],
        "summary": "List Activity",
        "description": "Returns the changes made to prompts, topics and prompt tags across your organization, newest first by default. Each entry names the website, the entity type, the kind of change (`created`, `updated`, `deleted`, `restored`, `paused`, `unpaused`), the affected entity ids and who made the change. Use it to find out what happened without re-listing every website.\n\n`entity_ids` is `null` when the affected set is not known (for example a bulk import); re-list that website's prompts with `GET /api/v1/prompts`. A `topic` or `prompt_tag` entry means the `topic_name` or `tags` of that website's prompts may have changed, so re-list the website in that case too. Changes made with an API key carry the key's id and name in `actor`, so you can skip your own writes. Changes made in the app carry the person's id and email in `actor.user`. Keys scoped to specific websites see the identity of members of those websites only; other people appear with `user: null`. Websites provisioned through `POST /api/v1/websites/provision` do not appear here; list a website once after provisioning it.\n\nTo mirror data, pin a window per sync run: set `since` to the previous run's `until`, set `until` to now minus one minute, pass `order=asc`, walk `page_num` until `pagination.has_more` is `false`, then store that `until` for the next run. `since` is exclusive and `until` inclusive, so consecutive windows neither overlap nor skip. With no `since` the walk covers the whole history, so `order=asc` with no bounds is a full export. Pagination uses `page_size + 1` lookahead: there is no total-count field.\n\nRequires a partner API key. Keys scoped to specific websites see only those websites.",
        "operationId": "listActivity",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "ISO 8601 timestamp. Only changes strictly after this instant. Omit to start from the beginning of the organization's history.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "description": "ISO 8601 timestamp. Only changes up to and including this instant. Pin it per sync run so pages cannot shift while you page.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "order",
            "in": "query",
            "description": "`desc` (default) lists the newest changes first. Use `asc` to export or sync in the order the changes happened.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["desc", "asc"],
              "default": "desc"
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "description": "Restrict to one website. Omit for the whole organization. A website outside your key's scope, or outside your organization, returns 403.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "entity_type",
            "in": "query",
            "description": "Comma-separated list of entity types to include. Omit for all.",
            "required": false,
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": ["prompt", "topic", "prompt_tag"]
              }
            }
          },
          {
            "name": "change_type",
            "in": "query",
            "description": "Comma-separated list of change types to include. Omit for all.",
            "required": false,
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "created",
                  "updated",
                  "deleted",
                  "restored",
                  "paused",
                  "unpaused"
                ]
              }
            }
          },
          {
            "name": "page_num",
            "in": "query",
            "description": "Zero-indexed page number.",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "description": "Number of entries per page (1-100).",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the page of changes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityListResponse"
                },
                "example": {
                  "activity": [
                    {
                      "id": "6f1c2a3e-5b7d-4e8f-9a0b-1c2d3e4f5a6b",
                      "occurred_at": "2026-09-20T08:14:03.512Z",
                      "website_id": "3b9d1e2f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
                      "entity_type": "prompt",
                      "change_type": "created",
                      "entity_ids": ["a1f0b2c3-d4e5-4f60-8172-839405a6b7c8"],
                      "actor": {
                        "type": "user",
                        "api_key_id": null,
                        "api_key_name": null,
                        "user": {
                          "id": "5e7a0000-0000-4000-8000-000000000001",
                          "email": "ada@example.com"
                        }
                      }
                    },
                    {
                      "id": "7a44b5c6-d7e8-4f90-a1b2-c3d4e5f6a7b8",
                      "occurred_at": "2026-09-20T08:15:41.007Z",
                      "website_id": "3b9d1e2f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
                      "entity_type": "prompt",
                      "change_type": "deleted",
                      "entity_ids": [
                        "c2d1e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                        "c2d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f"
                      ],
                      "actor": {
                        "type": "user",
                        "api_key_id": null,
                        "api_key_name": null,
                        "user": {
                          "id": "5e7a0000-0000-4000-8000-000000000001",
                          "email": "ada@example.com"
                        }
                      }
                    },
                    {
                      "id": "8b90c1d2-e3f4-4a5b-9c6d-7e8f9a0b1c2d",
                      "occurred_at": "2026-09-20T09:02:10.220Z",
                      "website_id": "9e07f1a2-b3c4-4d5e-8f60-718293a4b5c6",
                      "entity_type": "topic",
                      "change_type": "updated",
                      "entity_ids": ["d5510000-0000-4000-8000-000000000001"],
                      "actor": {
                        "type": "user",
                        "api_key_id": null,
                        "api_key_name": null,
                        "user": {
                          "id": "5e7a0000-0000-4000-8000-000000000001",
                          "email": "ada@example.com"
                        }
                      }
                    },
                    {
                      "id": "9c12d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
                      "occurred_at": "2026-09-20T11:30:00.918Z",
                      "website_id": "9e07f1a2-b3c4-4d5e-8f60-718293a4b5c6",
                      "entity_type": "prompt",
                      "change_type": "updated",
                      "entity_ids": null,
                      "actor": {
                        "type": "api_key",
                        "api_key_id": "a8f20000-0000-4000-8000-000000000002",
                        "api_key_name": "Production integration",
                        "user": null
                      }
                    }
                  ],
                  "pagination": {
                    "page_num": 0,
                    "page_size": 100,
                    "has_more": true
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request, invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "page_size_out_of_range": {
                    "value": {
                      "error": "page_size must be between 1 and 100"
                    }
                  },
                  "unknown_entity_type": {
                    "value": {
                      "error": "entity_type must be one of prompt, topic, prompt_tag"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden. The key's organization is not a partner, or the requested website is outside the key's scope or organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_a_partner": {
                    "value": {
                      "error": "Forbidden: partner API key required"
                    }
                  },
                  "website_out_of_scope": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/content/items": {
      "get": {
        "tags": ["Content"],
        "summary": "List Content Items",
        "description": "Returns every content item in a website's Content Hub, published or not: in-flight drafts, briefs, snipes, optimize and slice runs, scheduled and failed items, plus tracked pages. This is the enumeration path from a `sheet_id` to its unpublished rows. `POST /api/v1/content` lists only finished pipeline rows, with citation and impression metrics, so a sheet full of generated drafts appears empty there; use this endpoint to see them.\n\nReturns identity fields only (id, title, type, stage, sheet, URL, timestamps, target prompt ids), no metrics. Reads from the primary store and is uncached, so an item is listable the moment `POST /api/v1/content/generate` returns its `content_id`. Read a row's text with `GET /api/v1/content/{content_id}`.\n\n`stage` is the raw pipeline workflow state, not a publication flag: `null` means no pipeline record (most external and imported tracked pages), and manual editor items carry `generated`. Treat an item as published only when its stage is `done` (or it is an external or imported page) and it has a `url`; `done` without a `url` is an unpublished orphan.\n\nPassing the `sheet_id` of a view-type tab (see `sheet_type` on `GET /api/v1/content/sheets`) lists the shared main pool without the view's saved filters. Hidden content (`is_hidden = true`) is excluded. Pagination uses `page_size + 1` lookahead: `pagination.has_more === true` means the next page exists; there is no total-count field. Pass an unknown `sheet_id` or `prompt_id` (or one from another website) and the endpoint returns 403.\n\nAlso exposed as the MCP tool `list_content`.",
        "operationId": "listContentItems",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The website whose Content Hub to enumerate.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "sheet_id",
            "in": "query",
            "description": "Restrict to a single Content Hub tab. Use `GET /api/v1/content/sheets` to discover IDs. A view-type tab resolves to the shared main pool. Omit to span every tab.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "content_type",
            "in": "query",
            "description": "Restrict to a single content type. `athena_created` is a shortcut for the four Athena-generated subtypes (draft, snipe, optimize, slice). Omit to span every type.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "external",
                "imported",
                "athena_created",
                "draft",
                "snipe",
                "optimize",
                "slice",
                "manual"
              ]
            }
          },
          {
            "name": "stage",
            "in": "query",
            "description": "Restrict to a single pipeline stage. Matches the pipeline record only, so it can never match rows without one (most external and imported pages). Omit to span every stage.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "scheduled",
                "pending",
                "pending_brief",
                "generated_brief",
                "pending_article",
                "generated",
                "done",
                "failed"
              ]
            }
          },
          {
            "name": "prompt_id",
            "in": "query",
            "description": "Restrict to items written for this prompt (their targeting, the same prompt ids `POST /api/v1/content/generate` takes). Soft-deleted prompts still match.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page_num",
            "in": "query",
            "description": "Zero-indexed page number.",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "description": "Number of items per page (1-100).",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the page of content items.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentItemsListResponse"
                },
                "example": {
                  "content": [
                    {
                      "content_id": "11111111-2222-3333-4444-555555555555",
                      "title": "How to Apply Foundation on Mature Skin",
                      "type": "draft",
                      "stage": "generated",
                      "url": null,
                      "normalized_url": null,
                      "sheet_id": "00000000-0000-4000-8000-000000000001",
                      "sheet_name": "Drafts - sprint 1",
                      "topic_name": "Makeup for Mature Skin",
                      "prompt_ids": ["aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee"],
                      "prompt_count": 1,
                      "mark_as_done_time": null,
                      "created_at": "2026-09-01T20:59:53.000Z",
                      "updated_at": "2026-09-01T21:09:04.000Z"
                    }
                  ],
                  "pagination": {
                    "page_num": 0,
                    "page_size": 50,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request, invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_stage": {
                    "value": {
                      "error": "stage: Invalid option: expected one of \"scheduled\"|\"pending\"|\"pending_brief\"|\"generated_brief\"|\"pending_article\"|\"generated\"|\"done\"|\"failed\""
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, you don't have access to this website, or the `sheet_id` / `prompt_id` belongs to another website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "sheet": {
                    "value": {
                      "error": "Unauthorized access to this sheet"
                    }
                  },
                  "prompt": {
                    "value": {
                      "error": "Unauthorized access to this prompt"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}": {
      "get": {
        "tags": ["Content"],
        "summary": "Get Content Detail",
        "description": "Fetch the full detail of a single tracked content item \u2014 including the actual text: the content brief (`brief`) and the article/page body (`body`). `body` holds generated drafts, optimize rewrites, snipe articles, authored text, and scraped tracked-page bodies alike.\n\nUse this after listing tracked content (`POST /api/v1/content`) to read the text behind a `content_id`, or to poll `status` while generation runs \u2014 `generated_brief` means the brief is ready while the article is still being written. Also exposed as the MCP tool `get_content_detail`.\n\nFor an `optimize` item, `source_url` is the live page it is based on, available as soon as the item exists. `url` stays `null` until `POST /api/v1/content/{content_id}/publish` records the published page and marks the item `done`, so read `source_url` to link a request in review to its page without changing its `status`.\n\nTracked pages that have not been scraped yet return `null` text fields. Unknown or hidden `content_id` returns 404.",
        "operationId": "getContentDetail",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "description": "The UUID of the content item to fetch.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "description": "The website the content item belongs to.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the content item's full detail.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentDetailResponse"
                },
                "example": {
                  "content_id": "11111111-2222-3333-4444-555555555555",
                  "title": "Best CRMs for early-stage startups",
                  "url": "https://example.com/blog/best-crms",
                  "normalized_url": "example.com/blog/best-crms",
                  "source_url": null,
                  "type": "draft",
                  "sheet_id": "22222222-3333-4444-5555-666666666666",
                  "status": "generated",
                  "brief": "## Brief\n\nTarget the comparison angle for early-stage buyers\u2026",
                  "body": "# Best CRMs for early-stage startups\n\nChoosing a CRM before product-market fit\u2026",
                  "meta_description": "A practical comparison of CRMs for early-stage startups.",
                  "cited_urls": ["https://example.org/2026-crm-report"],
                  "internal_links": ["https://example.com/blog/crm-migration"],
                  "brief_cited_urls": ["https://example.org/2026-crm-report"],
                  "brief_internal_links": [
                    "https://example.com/blog/crm-migration"
                  ],
                  "optimize_summary": null,
                  "linkedin_post": null,
                  "x_post": null,
                  "facebook_post": null,
                  "instagram_post": null,
                  "reddit_post": null,
                  "topic_name": "CRM",
                  "prompts": [
                    {
                      "id": "77777777-8888-9999-aaaa-bbbbbbbbbbbb",
                      "prompt": "best CRM for early-stage startups",
                      "topic_name": "CRM",
                      "status": "active"
                    }
                  ],
                  "prompts_total": 1,
                  "mark_as_done_time": null,
                  "created_at": "2026-06-01T12:00:00.000Z",
                  "updated_at": "2026-06-02T08:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "Bad request \u2014 invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_content_id": {
                    "value": {
                      "error": "content_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 you don't have access to this website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Unauthorized access to this website"
                }
              }
            }
          },
          "404": {
            "description": "Content not found for this website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Content not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["Content"],
        "operationId": "content.update",
        "summary": "Rename Content",
        "description": "Rename a content row's title. URL editing is not supported \u2014 URL is the content asset's stable identity and cannot be changed here.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "enum": [true],
                      "type": "boolean"
                    }
                  },
                  "required": ["success"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  }
                },
                "required": ["website_id", "title"]
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Content"],
        "operationId": "content.delete",
        "summary": "Delete Content",
        "description": "Delete a content row. Destructive: physical row delete, no undo. Powers delete-and-retry. Bulk delete is out of scope.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "enum": [true],
                      "type": "boolean"
                    }
                  },
                  "required": ["success"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/pitches": {
      "post": {
        "tags": ["Pitch Workspace"],
        "summary": "Create a pitch report",
        "operationId": "createPitch",
        "description": "Generate a Pitch Workspace report from a public website URL. Requires a global organization API key, Pitch Workspace entitlement, and available pitch allowance. Returns a durable pitch ID while research runs. Poll GET /api/v1/pitches/{pitch_id} until pitch.status is completed or failed. The report URL is accessible to anyone holding it. Each admitted request consumes one pitch, including attempts that fail during generation. Retrying the same organization and Idempotency-Key with the same normalized input reuses the pitch; different input returns 409. Use a new key to deliberately request a fresh snapshot. Generation does not send email.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Stable identifier for one logical request. Preserve it on retries."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": ["website_url"],
                "properties": {
                  "website_url": {
                    "type": "string",
                    "maxLength": 2000,
                    "example": "https://example.com"
                  },
                  "country": {
                    "type": "string",
                    "maxLength": 100,
                    "default": "United States"
                  },
                  "language": {
                    "type": "string",
                    "maxLength": 100,
                    "default": "English"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted, or the existing result for an idempotent retry. Generation may take several minutes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["pitch_id", "status", "report_url"],
                  "properties": {
                    "pitch_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["processing", "completed", "failed"]
                    },
                    "report_url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, URL or missing Idempotency-Key."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "Global organization key, Pitch Workspace entitlement or pitch allowance required."
          },
          "404": {
            "description": "The report for this request was deleted."
          },
          "409": {
            "description": "Idempotency-Key already used with different input."
          },
          "429": {
            "description": "Rate limit or three concurrent reports exceeded. Honor Retry-After."
          },
          "500": {
            "description": "Admission could not be confirmed. Retry with the same Idempotency-Key promptly; contact support if unresolved."
          }
        }
      },
      "get": {
        "tags": ["Pitch Workspace"],
        "summary": "List Pitches",
        "description": "Returns all non-deleted pitch workspace reports for the calling organization, ordered by creation date (newest first). Pitches are org-level resources and are not scoped to a single website.\n\nRequires a **global (organization-scoped) API key**. Website-scoped keys are rejected with `403 Forbidden`.",
        "operationId": "listPitches",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the list of pitches.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pitches": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PitchSummary"
                      }
                    }
                  },
                  "required": ["pitches"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 a website-scoped API key was used. Pitches are org-level resources; use a global API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/pitches/{pitch_id}": {
      "get": {
        "tags": ["Pitch Workspace"],
        "summary": "Get Pitch Report",
        "description": "Returns a single pitch report by ID, including the company metadata, generated prompts, tracked competitors, brand and competitor attributes, top citing sources, and aggregate metrics (brand mentions, sentiment, response rate).\n\nRequires a **global (organization-scoped) API key**. Website-scoped keys are rejected with `403 Forbidden`. Returns `404 Not Found` if the pitch does not exist, has been deleted, or belongs to a different organization.",
        "operationId": "getPitch",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "pitch_id",
            "in": "path",
            "description": "The UUID of the pitch to retrieve.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the full pitch report.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PitchReport"
                }
              }
            }
          },
          "400": {
            "description": "Bad request \u2014 invalid `pitch_id` format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Invalid pitch ID format"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 a website-scoped API key was used. Pitches are org-level resources; use a global API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Forbidden: global API key required"
                }
              }
            }
          },
          "404": {
            "description": "Pitch not found in the calling organization, or has been deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Pitch not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sources": {
      "post": {
        "tags": ["Sources"],
        "summary": "List Sources (by root domain)",
        "description": "Returns the top cited sources for a website, grouped by root domain. Each row carries citation, mention, brand-mention, and impression metrics for the requested date range, plus a `default_source_type` classification (`owned` / `competitor` / `partner` / `third_party`).\n\nCompanion to [POST /api/v1/source-pages](/api-reference/sources/list-source-pages-per-url), which returns the same data grouped per URL (one row per cited page) instead of per root domain. Ownership and source tags use the centralized URL-pattern rules. Domain summaries consider whole-host rules only; path and query rules apply to page-level results. Explicit www hosts remain separate when their matching rules differ from the apex.",
        "operationId": "listSources",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SourcesListRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with the page of sources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourcesListResponse"
                },
                "example": {
                  "sources": [
                    {
                      "root_domain": "wikipedia.org",
                      "total_mentions": 124,
                      "response_count": 86,
                      "estimated_impressions": 18400,
                      "domain_count": 31,
                      "mention_percentage": 12.3,
                      "citation_percentage": 14.1,
                      "competitor_mention_percentage": 3.2,
                      "brand_mention_percentage": 8.9,
                      "mentions_count": 47,
                      "responses_mentioned_count": 39,
                      "competitor_ids": [],
                      "default_source_type": "third_party",
                      "source_type_ids": [],
                      "first_seen": "2024-01-04"
                    }
                  ],
                  "pagination": {
                    "page_num": 0,
                    "page_size": 30,
                    "total": 142
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request \u2014 invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 you don't have access to this website, or a sub-resource ID (`prompt_ids`, `competitor_ids`, `location_ids`) belongs to another website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "prompts": {
                    "value": {
                      "error": "Unauthorized access to these prompts"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Website not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/source-pages": {
      "post": {
        "tags": ["Sources"],
        "summary": "List Source Pages (per URL)",
        "description": "Returns individual cited URLs for a website with citation, mention, and impression metrics \u2014 one row per `normalized_url`. Each row also includes a `daily_mentions` sparkline (citation percentage per day across the date range) and the same source-type classification as [POST /api/v1/sources](/api-reference/sources/list-sources-by-root-domain).\n\nUse this when you need URL-level resolution (e.g. drill into which specific articles on a partner domain drove citations). For the root-domain rollup, use [POST /api/v1/sources](/api-reference/sources/list-sources-by-root-domain). Ownership and source tags match original citation URLs, preserving host distinctions, path case, and query constraints. Results retain their normalized URL identifiers and pagination, combining labels from matching citation variants within each page row.",
        "operationId": "listSourcePages",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SourcePagesListRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with the page of cited URLs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourcePagesListResponse"
                },
                "example": {
                  "pages": [
                    {
                      "normalized_url": "wikipedia.org/wiki/Customer_Relationship_Management",
                      "domain": "en.wikipedia.org",
                      "root_domain": "wikipedia.org",
                      "normalized_root_domain": "wikipedia.org",
                      "total_mentions": 24,
                      "estimated_impressions": 3400,
                      "citation_percentage": 2.7,
                      "mentions_count": 9,
                      "competitor_ids": [],
                      "default_source_type": "third_party",
                      "source_type_ids": [],
                      "first_seen": "2024-01-07",
                      "daily_mentions": [
                        {
                          "date": "2024-01-07",
                          "citation_percentage": 0.4
                        },
                        {
                          "date": "2024-01-08",
                          "citation_percentage": 0.6
                        }
                      ]
                    }
                  ],
                  "pagination": {
                    "page_num": 0,
                    "page_size": 30,
                    "total": 412
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request \u2014 invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "invalid_website_id": {
                    "value": {
                      "error": "website_id must be a uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden \u2014 you don't have access to this website, or a sub-resource ID (`prompt_ids`, `competitor_ids`, `location_ids`, `prompt_tags`) belongs to another website.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "prompts": {
                    "value": {
                      "error": "Unauthorized access to these prompts"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Website not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Website not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-search-value": {
      "get": {
        "operationId": "getAiSearchValue",
        "summary": "Get AI Search Value",
        "description": "AI Search Value for a website: topic-market value, captured value range, headroom, coverage, value-weighted AI share of voice, per-topic detail, and modeled attributed contribution.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "assumptions_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "computed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "has_computed_valuations": {
                      "type": "boolean"
                    },
                    "is_stale_value": {
                      "type": "boolean"
                    },
                    "market": {
                      "type": "object",
                      "properties": {
                        "value_usd_mo": {
                          "type": "number"
                        },
                        "topics_priced": {
                          "type": "number"
                        },
                        "topics_total": {
                          "type": "number"
                        },
                        "coverage_pct": {
                          "type": "number"
                        },
                        "current_sov_pct": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "value_usd_mo",
                        "topics_priced",
                        "topics_total",
                        "coverage_pct",
                        "current_sov_pct"
                      ]
                    },
                    "captured": {
                      "type": "object",
                      "properties": {
                        "conservative": {
                          "type": "number"
                        },
                        "expected": {
                          "type": "number"
                        },
                        "upside": {
                          "type": "number"
                        }
                      },
                      "required": ["conservative", "expected", "upside"]
                    },
                    "headroom": {
                      "type": "object",
                      "properties": {
                        "conservative": {
                          "type": "number"
                        },
                        "expected": {
                          "type": "number"
                        },
                        "upside": {
                          "type": "number"
                        }
                      },
                      "required": ["conservative", "expected", "upside"]
                    },
                    "measured_responses": {
                      "type": "number"
                    },
                    "topics": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "topic_id": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "local_intent": {
                            "type": "boolean"
                          },
                          "share_basis": {
                            "type": "string"
                          },
                          "pw_sov_pct": {
                            "type": "number"
                          },
                          "mix_adjusted_share_pct": {
                            "type": "number"
                          },
                          "mention_rate_pct": {
                            "type": "number"
                          },
                          "drift_pp": {
                            "type": "number"
                          },
                          "standard_error_pp": {
                            "type": "number"
                          },
                          "responses_28d": {
                            "type": "number"
                          },
                          "models_measured": {
                            "type": "number"
                          },
                          "personas_measured": {
                            "type": "number"
                          },
                          "locations_measured": {
                            "type": "number"
                          },
                          "captured": {
                            "type": "object",
                            "properties": {
                              "conservative": {
                                "type": "number"
                              },
                              "expected": {
                                "type": "number"
                              },
                              "upside": {
                                "type": "number"
                              }
                            },
                            "required": ["conservative", "expected", "upside"]
                          },
                          "headroom": {
                            "type": "object",
                            "properties": {
                              "conservative": {
                                "type": "number"
                              },
                              "expected": {
                                "type": "number"
                              },
                              "upside": {
                                "type": "number"
                              }
                            },
                            "required": ["conservative", "expected", "upside"]
                          },
                          "counted_in_total": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "topic_id",
                          "category",
                          "local_intent",
                          "share_basis",
                          "pw_sov_pct",
                          "mix_adjusted_share_pct",
                          "mention_rate_pct",
                          "drift_pp",
                          "standard_error_pp",
                          "responses_28d",
                          "models_measured",
                          "personas_measured",
                          "locations_measured",
                          "captured",
                          "headroom",
                          "counted_in_total"
                        ]
                      }
                    },
                    "merge_suggestions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "topic_id_a": {
                            "type": "string"
                          },
                          "topic_id_b": {
                            "type": "string"
                          },
                          "name_a": {
                            "type": "string"
                          },
                          "name_b": {
                            "type": "string"
                          },
                          "similarity": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "topic_id_a",
                          "topic_id_b",
                          "name_a",
                          "name_b",
                          "similarity"
                        ]
                      }
                    },
                    "contribution": {
                      "type": "object",
                      "properties": {
                        "modeled_attributed": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "conservative": {
                                  "type": "number"
                                },
                                "expected": {
                                  "type": "number"
                                },
                                "upside": {
                                  "type": "number"
                                }
                              },
                              "required": ["conservative", "expected", "upside"]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "attributed_share": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "attribution_unavailable": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "modeled_attributed",
                        "attributed_share",
                        "attribution_unavailable"
                      ]
                    },
                    "forecast": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "created_at": {
                              "type": "string"
                            },
                            "days_elapsed": {
                              "type": "number"
                            },
                            "share_delta_pp": {
                              "type": "number"
                            },
                            "share_vs_do_nothing_pp": {
                              "type": "number"
                            },
                            "captured_delta_expected": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "id",
                            "created_at",
                            "days_elapsed",
                            "share_delta_pp",
                            "share_vs_do_nothing_pp",
                            "captured_delta_expected"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "assumptions_version",
                    "computed_at",
                    "has_computed_valuations",
                    "is_stale_value",
                    "market",
                    "captured",
                    "headroom",
                    "measured_responses",
                    "topics",
                    "merge_suggestions",
                    "contribution",
                    "forecast"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "tags": ["AI Search Value"],
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/api/v1/content/generate": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.pipeline.start",
        "summary": "Start Content Pipeline",
        "description": "Generate an article or content brief in AthenaHQ. Fetches source URLs, sends source material to external AI providers, and consumes content credits. Obtain user approval before calling. Does not publish to a website or CMS. For draft mode, auto_approve defaults to true; set false to generate only a brief and wait for approve_brief. Poll GET /api/v1/content/{content_id}/status using each returned content_ids value. Slice mode returns slice_titles and an empty content_ids array; generated items can be listed with GET /api/v1/content/items. To save an already-written article without generation or credit use, call the MCP add_content tool.",
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "enum": ["generating"],
                      "type": "string"
                    },
                    "slice_titles": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": ["content_ids", "status"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "mode": {
                    "type": "string",
                    "enum": ["draft", "snipe", "optimize", "slice"],
                    "description": "draft: generate a brief and optionally an article from tracked prompts. snipe: draft an article using a competitor URL as input. optimize: improve an existing page for AI search. slice: turn one source URL into several articles."
                  },
                  "title": {
                    "type": "string",
                    "description": "Article title. Required for draft, snipe, and optimize modes."
                  },
                  "url": {
                    "type": "string",
                    "description": "Source page URL. Required for snipe, optimize, and slice modes. A URL without a protocol, such as example.com/article, is accepted."
                  },
                  "prompt_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Existing tracked prompt UUIDs, up to 100. Required and nonempty for draft; omit for slice. Use IDs from the website's tracked prompt list; never invent them."
                  },
                  "custom_instructions": {
                    "type": "string"
                  },
                  "brand_kit_id": {
                    "type": "string"
                  },
                  "sheet_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "use_content_memories": {
                    "type": "boolean"
                  },
                  "auto_approve": {
                    "type": "boolean",
                    "description": "Draft mode only. Defaults to true, which continues from brief generation to article generation. Set false to pause at generated_brief until approve_brief is called."
                  },
                  "content_format_type": {
                    "type": "string"
                  },
                  "scrape_additional_links": {
                    "type": "boolean"
                  },
                  "kb_mode": {
                    "type": "string",
                    "enum": ["auto", "manual", "none"]
                  },
                  "selected_topic_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "pinned_claim_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "use_kb_internal_links": {
                    "type": "boolean"
                  },
                  "fact_review": {
                    "type": "object",
                    "description": "A reviewed fact selection from the fact preview. When present (draft mode with the knowledge base enabled), generation uses exactly these pillars and kept facts instead of computing a selection, and pinned_claim_ids no longer influences selection. Claims without a pillar are never used: a kept id that resolves to an unfiled claim is dropped and reported in the run's selection outcome.",
                    "properties": {
                      "topic_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "kept_claim_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "excluded_claim_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": [
                      "topic_ids",
                      "kept_claim_ids",
                      "excluded_claim_ids"
                    ]
                  },
                  "rec_id": {
                    "type": "string"
                  },
                  "rec_kind": {
                    "type": "string",
                    "enum": ["on_page_topic", "on_page_snipe"]
                  },
                  "pdf_file_name_or_r2_key": {
                    "type": "string"
                  }
                },
                "required": ["website_id", "mode"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}/draft": {
      "get": {
        "tags": ["Content"],
        "operationId": "content.getDraft",
        "summary": "Get Content Draft",
        "description": "Read the current draft text of a content item \u2014 the article body as it stands right now, including every revision applied so far. Use this before revise_content to see what you are changing, and after it to confirm the result. A status of generated_brief means the brief is ready while the article is still being written, so body may still be empty. For the full record (cited urls, links, social posts) use get_content_detail instead.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string"
                    },
                    "title": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "body": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "meta_description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "latest_version_number": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "content_id",
                    "title",
                    "body",
                    "brief",
                    "meta_description",
                    "status",
                    "latest_version_number"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/content/{content_id}/revise": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.revise",
        "summary": "Revise Content Draft",
        "description": "Rewrite an existing content draft from a natural-language instruction (for example: 'tighten the intro', 'add a section on pricing', 'remove the second half'). An AI model performs the rewrite server-side, so the result is generated text, not your literal wording; when you already have the exact replacement text, use the edit endpoint instead. Applies the change to the whole article and records it as a new version, so earlier passes stay recoverable via get_content_versions / restore_content_version. Iterate by calling it again \u2014 each call starts from the current text, so no version id is needed. Use this instead of create_content to change a draft; it edits in place rather than generating a new piece. The returned body is always the complete replacement article, never just the edited passage; compare body_word_count with previous_body_word_count to confirm nothing unexpected was lost.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string"
                    },
                    "body": {
                      "type": "string"
                    },
                    "version_number": {
                      "type": "integer"
                    },
                    "version_id": {
                      "type": "string"
                    },
                    "body_word_count": {
                      "type": "integer"
                    },
                    "previous_body_word_count": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "content_id",
                    "body",
                    "version_number",
                    "version_id",
                    "body_word_count",
                    "previous_body_word_count"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "instruction": {
                    "type": "string"
                  }
                },
                "required": ["website_id", "instruction"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}/edit": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.edit",
        "summary": "Edit Content Draft",
        "description": "Apply exact find-and-replace edits to a content draft's article body. Deterministic, no AI model involved: your replacement text lands verbatim (use the revise endpoint when you want an AI rewrite from an instruction). Each edit's find text must match the current body exactly once; zero or multiple matches fail the whole call with 400 and nothing is saved, so extend the find text until it is unique. Edits apply in order, later ones see earlier results, and the batch is recorded as one new version, recoverable via the versions endpoints. Pass expected_version_number from the draft endpoint to fail with 409 when a new version was recorded after your read (a revision, edit, or restore). An app autosave changes the body without recording a version; that drift is caught by the anchors themselves, since a moved or vanished find text fails the call.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string"
                    },
                    "body": {
                      "type": "string"
                    },
                    "version_number": {
                      "type": "integer"
                    },
                    "version_id": {
                      "type": "string"
                    },
                    "body_word_count": {
                      "type": "integer"
                    },
                    "previous_body_word_count": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "content_id",
                    "body",
                    "version_number",
                    "version_id",
                    "body_word_count",
                    "previous_body_word_count"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "edits": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "properties": {
                        "find": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 10000
                        },
                        "replace": {
                          "type": "string",
                          "maxLength": 10000
                        }
                      },
                      "required": ["find", "replace"]
                    }
                  },
                  "expected_version_number": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": ["website_id", "edits"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}/brief/revise": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.reviseBrief",
        "summary": "Revise Content Brief",
        "description": "Rewrite a content brief from a natural-language instruction (for example: 'add a section on pricing objections', 'cut the competitor comparison'). An AI model performs the rewrite server-side, so the result is generated text, not your literal wording. Records each pass as a version; iterate by calling it again, since each call starts from the current brief. Most useful while a piece waits at status generated_brief, where the brief still shapes what the article will say \u2014 call approve_brief once it reads right. It also works after the article exists, to correct the brief for a later regeneration; note that revising the brief does NOT rewrite an already-generated article, so use revise_content for that.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string"
                    },
                    "brief": {
                      "type": "string"
                    },
                    "version_number": {
                      "type": "integer"
                    },
                    "version_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "content_id",
                    "brief",
                    "version_number",
                    "version_id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "instruction": {
                    "type": "string"
                  }
                },
                "required": ["website_id", "instruction"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}/brief/approve": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.approveBrief",
        "summary": "Approve Content Brief",
        "description": "Approve a content brief and start writing the article from it. Only valid while the piece is at status generated_brief. The article is generated from the brief exactly as it currently stands, including any revisions made with revise_brief or edits made in the app. Consumes content credits; poll get_content_status afterwards, then read the result with get_content_draft.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string"
                    },
                    "status": {
                      "enum": ["generating"],
                      "type": "string"
                    }
                  },
                  "required": ["content_id", "status"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  }
                },
                "required": ["website_id"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}/versions": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.versions.list",
        "summary": "List Content Versions",
        "description": "List the saved versions of a content item, newest first. Each entry carries its version number, label, how it was produced, and who made it. Use it to see how a draft evolved, then get_content_version to read a specific one, or restore_content_version to go back to it.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "versions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "version_id": {
                            "type": "string"
                          },
                          "version_number": {
                            "type": "integer"
                          },
                          "label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "change_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "created_by_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "version_id",
                          "version_number",
                          "label",
                          "change_type",
                          "created_at",
                          "created_by_name"
                        ]
                      }
                    },
                    "total_count": {
                      "type": "integer"
                    }
                  },
                  "required": ["versions", "total_count"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  }
                },
                "required": ["website_id"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}/versions/{version_id}": {
      "get": {
        "tags": ["Content"],
        "operationId": "content.versions.get",
        "summary": "Get Content Version",
        "description": "Read the full text of one saved version of a content item. Use it to compare two passes (fetch both and diff them yourself) or to check what an earlier version said before restoring it.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version_id": {
                      "type": "string"
                    },
                    "version_number": {
                      "type": "integer"
                    },
                    "body": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "meta_description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "change_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "version_id",
                    "version_number",
                    "body",
                    "brief",
                    "meta_description",
                    "label",
                    "change_type",
                    "created_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/content/{content_id}/versions/{version_id}/restore": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.restoreVersion",
        "summary": "Restore Content Version",
        "description": "Bring an earlier version's text back as the current draft \u2014 use it when a later pass came out worse than an earlier one. Nothing is deleted: the restored text is appended as a new version on top of the history, so the passes in between remain readable and restorable.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string"
                    },
                    "body": {
                      "type": "string"
                    },
                    "version_number": {
                      "type": "integer"
                    },
                    "version_id": {
                      "type": "string"
                    },
                    "restored_from_version_number": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "content_id",
                    "body",
                    "version_number",
                    "version_id",
                    "restored_from_version_number"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  }
                },
                "required": ["website_id"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/{content_id}/publish": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.publish",
        "summary": "Mark Content as Published",
        "description": "Record an already-published article's URL in AthenaHQ for citation and mention tracking. Does not upload or publish content to a website or CMS. Call only after the article is live. Sets the first publication time and moves the pipeline stage to done. A first publish requires a finished article (stage generated), with one exception: an optimize draft is created from a page that is already live and can be marked published while it waits at stage pending, as long as no Athena review is running on it. Briefs, still-generating or failed pieces, optimize drafts with a review in flight, and items with a scheduled CMS publish are rejected with 409 and the reason. Pass the exact public URL of the live page (a bare domain path like acme.com/blog/post is fine; the protocol is stripped on store). Calling it again on an already-published item (including external and imported pages, which are live by definition) updates the tracked URL only, keeping the original publish time. This is the only way to set a content URL over the API; the rename endpoint is deliberately title-only.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string",
                      "nullable": true
                    },
                    "url": {
                      "type": "string"
                    },
                    "published_at": {
                      "type": "string",
                      "nullable": true
                    },
                    "already_published": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "content_id",
                    "title",
                    "url",
                    "published_at",
                    "already_published"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict: the piece has no finished article to publish (brief, generating, or failed stage), an Optimize review is still running on it, or it has a scheduled CMS publish",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  }
                },
                "required": ["website_id", "url"]
              }
            }
          }
        }
      }
    },
    "/api/v1/content/track": {
      "post": {
        "tags": ["Content"],
        "operationId": "content.track_urls",
        "summary": "Track External URLs",
        "description": "Register existing pages or third-party URLs as tracked Content Hub items so Athena attributes citations and mentions to them. Creates external content rows from bare URLs with no generation and no credit cost. Tracking starts immediately: the normalized URL becomes the citation/metric join key, so pages cited in the website's monitored AI responses accrue metrics with no publish step (use it for guest posts, partner placements, or any page Athena did not generate). Idempotent per URL: a URL already present on the website (any content type) is not duplicated; the response lists it under skipped with the existing content_id and type. Check that type before chaining destructive calls (a skip can resolve to first-party generated content that shares the URL). Rows are created without page text, which citation tracking does not need; the body can be filled from the app later. Duplicate URLs within one call (including tracking-param variants of the same page) collapse to one row, first occurrence wins. Optional sheet_id files rows under a Content Hub tab; view-type tabs resolve to the main pool (null), echoed per row. Optional per-URL fields set the customer's own Content Hub columns on the created row, addressed by column name as shown on the destination tab (text, number, date, checkbox, link, and multi-select columns; unknown multi-select options are created). An unknown column name or a value that does not fit the column type rejects the whole call and nothing is tracked; skipped URLs keep their existing values. Each created and skipped entry includes destination_name and content_hub_url. Share these with the user alongside the created and skipped counts. The link opens the specific item with its website and destination selected. Omitting sheet_id uses the shared pool regardless of the currently open browser tab. A skipped URL remains in its existing tab, even when a different sheet_id was requested.",
        "responses": {
          "201": {
            "description": "Created. Also returned when every URL was already tracked (idempotent success with created_count 0).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "created_count": {
                      "type": "number"
                    },
                    "skipped_count": {
                      "type": "number"
                    },
                    "created": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "content_id": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string",
                            "description": "The stored, protocol-less URL (display form)."
                          },
                          "destination_name": {
                            "type": "string",
                            "description": "The actual destination tab's name, or Shared pool when no shared-pool view exists."
                          },
                          "content_hub_url": {
                            "type": "string",
                            "format": "uri",
                            "description": "Opens the item in Content Hub with its website and destination tab selected."
                          },
                          "sheet_id": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "content_id",
                          "url",
                          "sheet_id",
                          "destination_name",
                          "content_hub_url"
                        ]
                      }
                    },
                    "skipped": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "content_id": {
                            "type": "string",
                            "description": "The already-existing row this input URL resolved to."
                          },
                          "url": {
                            "type": "string",
                            "description": "The cleaned input URL that was skipped."
                          },
                          "destination_name": {
                            "type": "string",
                            "description": "The existing row's actual destination, which may differ from the requested tab."
                          },
                          "content_hub_url": {
                            "type": "string",
                            "format": "uri",
                            "description": "Opens the existing item at its current Content Hub location. Skipped rows are not moved."
                          },
                          "type": {
                            "type": "string",
                            "description": "The existing row's content type. external/imported means the URL was already tracked; any other value (draft, snipe, ...) means it collided with first-party generated content sharing the join key - check before chaining destructive calls."
                          },
                          "sheet_id": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "content_id",
                          "url",
                          "type",
                          "sheet_id",
                          "destination_name",
                          "content_hub_url"
                        ]
                      }
                    }
                  },
                  "required": [
                    "success",
                    "created_count",
                    "skipped_count",
                    "created",
                    "skipped"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed (invalid URL in the batch, sheet_id not on this website, or a field naming an unknown column or a value that does not fit its type; nothing is written)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "description": "The website to track the URLs on."
                  },
                  "urls": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 500,
                    "description": "Pages to track. A bare domain path like acme.com/blog/post is fine; the protocol is stripped on store.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2048
                        },
                        "title": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 500,
                          "description": "Optional display title. Omitted: derived from the URL slug."
                        },
                        "fields": {
                          "type": "array",
                          "maxItems": 50,
                          "description": "Optional values for the customer-created Content Hub columns on the destination tab, written on the created row. Not applied to skipped URLs. Each column may appear once per URL.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "column": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200,
                                "description": "Column name as shown on the tab (case-insensitive). Writable types: text, number, date, checkbox, link, multi_select. Generated columns (Ask Athena, approval, OG image, ...) are rejected."
                              },
                              "value": {
                                "description": "Value in the column's type: string for text; http(s) URL string for link; number or numeric string for number; ISO 8601 date string (2026-09-01 or 2026-09-01T10:00:00Z, other formats are rejected; a date-only value is stored as UTC midnight) for date; boolean (or true/false, yes/no) for checkbox; array of option labels, or a comma-separated string, for multi_select (50 labels at most either way). Unknown multi-select options are created; existing ones match case-insensitively.",
                                "oneOf": [
                                  {
                                    "type": "string",
                                    "maxLength": 10000
                                  },
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "array",
                                    "maxItems": 50,
                                    "items": {
                                      "type": "string",
                                      "maxLength": 200
                                    }
                                  }
                                ]
                              }
                            },
                            "required": ["column", "value"]
                          }
                        }
                      },
                      "required": ["url"]
                    }
                  },
                  "sheet_id": {
                    "type": "string",
                    "nullable": true,
                    "description": "Content Hub tab to file the new rows under. View-type tabs resolve to the main pool (null)."
                  }
                },
                "required": ["website_id", "urls"]
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/content/{content_id}/status": {
      "get": {
        "tags": ["Content"],
        "operationId": "content.pipeline.status",
        "summary": "Get Content Pipeline Status",
        "description": "Get the normalized pipeline status (running | succeeded | failed) for one content row, plus the raw stage behind it. Read-only. Poll once per contentId returned by create_content (content.pipeline.start). A stage of generated_brief with status running means the brief is ready and waiting: for a non-auto-approve draft it stays there until the brief approve endpoint is called, so do not treat running as always in progress.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["running", "succeeded", "failed"]
                    },
                    "stage": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "scheduled",
                            "pending",
                            "pending_brief",
                            "generated_brief",
                            "pending_article",
                            "generated",
                            "done",
                            "failed"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Raw pipeline stage behind the normalized status. Null when no generation row exists yet."
                    }
                  },
                  "required": ["status", "stage"]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request: validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          },
          "500": {
            "description": "Internal Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": ["error"]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "content_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/attributes": {
      "get": {
        "tags": ["Attributes"],
        "summary": "List Attributes",
        "description": "Returns the direction-neutral brand-perception attributes tracked for a website. Use positive to select the positive or negative observation series; it defaults to true. Use this to discover attribute ids, then POST /api/v1/attributes/cumulative for prevalence, or POST /api/v1/attributes/time-series for one attribute's trend. Attributes the customer has removed are not returned.",
        "operationId": "listAttributes",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "description": "The ID of the website to retrieve attributes for",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "positive",
            "in": "query",
            "required": false,
            "description": "Observation direction to select. Defaults to the positive series.",
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with list of attributes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "attributes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Attribute"
                      }
                    }
                  },
                  "required": ["attributes"]
                },
                "example": {
                  "attributes": [
                    {
                      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "name": "Affordable",
                      "positive": true
                    },
                    {
                      "id": "9c858901-8a57-4791-81fe-4c455b099bc9",
                      "name": "Slow Support",
                      "positive": false
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - API key cannot access this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/attributes/cumulative": {
      "post": {
        "tags": ["Attributes"],
        "summary": "Cumulative Attribute Metrics",
        "description": "Returns directional prevalence for each direction-neutral brand-perception attribute. The optional top-level `positive` request field selects positive or negative observations and defaults to true. `total_responses` is the denominator: sampled, successfully analyzed responses in the date range that mention the brand. An analyzed response with no supported attribute claim remains in the denominator. Attributes nobody mentioned are returned with response_count 0 rather than omitted.",
        "operationId": "getCumulativeAttributeMetrics",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CumulativeAttributeMetricsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with attribute metrics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AttributeMetric"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "attribute_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "attribute_name": "Affordable",
                      "positive": true,
                      "response_count": 12,
                      "total_responses": 40,
                      "percentage": 30
                    },
                    {
                      "attribute_id": "9c858901-8a57-4791-81fe-4c455b099bc9",
                      "attribute_name": "Slow Support",
                      "positive": false,
                      "response_count": 0,
                      "total_responses": 40,
                      "percentage": 0
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - API key cannot access this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website or attribute does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/attributes/competitors": {
      "post": {
        "tags": ["Attributes"],
        "summary": "Competitor Attribute Metrics",
        "description": "Returns directional attribute prevalence per tracked competitor. The optional top-level `positive` request field selects positive or negative observations and defaults to true. `total_responses` is per-competitor: sampled, successfully analyzed responses in the date range that mention that competitor. Returns one row per competitor per attribute; narrow with filters.competitor_ids. Competitors with no responses in the date range are omitted.",
        "operationId": "getCompetitorAttributeMetrics",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttributeMetricsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with per-competitor attribute metrics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CompetitorAttributeMetric"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "competitor_id": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
                      "competitor_name": "Globex",
                      "attribute_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "attribute_name": "Affordable",
                      "positive": true,
                      "response_count": 5,
                      "total_responses": 20,
                      "percentage": 25
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - API key cannot access this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website or attribute does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/attributes/time-series": {
      "post": {
        "tags": ["Attributes"],
        "summary": "Attribute Time Series",
        "description": "Returns the daily directional trend for one attribute, brand and competitors side by side. Requires an attribute_id. The optional top-level `positive` request field selects positive or negative observations and defaults to true. Days with no data are returned as zeros. Denominators are per-side sampled, successfully analyzed responses that mention the entity. Competitor figures aggregate all tracked competitors unless filters.competitor_ids narrows them.",
        "operationId": "getAttributeTimeSeries",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttributeTimeSeriesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with the daily series",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AttributeTimeSeriesEntry"
                      }
                    }
                  },
                  "required": ["data"]
                },
                "example": {
                  "data": [
                    {
                      "date": "2026-07-15",
                      "brand_count": 1,
                      "brand_total": 2,
                      "brand_percentage": 50,
                      "competitor_count": 0,
                      "competitor_total": 0,
                      "competitor_percentage": 0
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - API key cannot access this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website or attribute does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/attributes/observations": {
      "post": {
        "tags": ["Attributes"],
        "summary": "Attribute Observations",
        "description": "Returns individual brand trait observations: each row is one statement an AI response made about one entity (your brand or a competitor) for one attribute, with the supporting response excerpt as `text_span`. `score` runs from -1 to 1 and its sign always matches `positive`; its magnitude (0.1 to 1.0) is how strongly the wording praises or criticizes. `score` is `null` when the observation was not scored, because it was extracted before scoring existed or has no valid value. If you only need the direction, use `score ?? (positive ? 1 : -1)`. Omit `positive` for both directions. `sort: \"intensity\"` (the default) returns the strongest observations first with unscored ones last; `sort: \"recent\"` returns the newest first. A page can hold fewer than `page_size` rows when an excerpt is no longer available, so use `has_more` to decide whether to fetch the next page. Also available as the MCP tool `get_attribute_observations`.",
        "operationId": "getAttributeObservations",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttributeObservationsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with a page of observations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AttributeObservation"
                      }
                    },
                    "page_num": {
                      "type": "integer",
                      "description": "Zero-indexed page number returned."
                    },
                    "page_size": {
                      "type": "integer",
                      "description": "Maximum rows per page."
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "`true` if another page is available."
                    }
                  },
                  "required": ["data", "page_num", "page_size", "has_more"]
                },
                "example": {
                  "data": [
                    {
                      "observation_id": "0b7c3f7e-2d4a-4c1e-9f3b-6a2e8d1c4b5a",
                      "response_id": "7d9e1a2b-3c4d-4e5f-8a6b-9c0d1e2f3a4b",
                      "entity_id": "123e4567-e89b-12d3-a456-426614174000",
                      "entity_name": "Acme",
                      "is_website": true,
                      "attribute_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "attribute_name": "Affordable",
                      "positive": true,
                      "score": 0.9,
                      "text_span": "Acme is by far the most affordable option for small teams.",
                      "model": "chatgpt",
                      "created_at": "2026-09-14T08:21:05Z"
                    },
                    {
                      "observation_id": "5e6f7a8b-9c0d-4e1f-8a2b-3c4d5e6f7a8b",
                      "response_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
                      "entity_id": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
                      "entity_name": "Globex",
                      "is_website": false,
                      "attribute_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "attribute_name": "Affordable",
                      "positive": false,
                      "score": null,
                      "text_span": "Globex is priced above most alternatives.",
                      "model": "perplexity",
                      "created_at": "2026-08-02T17:44:39Z"
                    }
                  ],
                  "page_num": 0,
                  "page_size": 40,
                  "has_more": false
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - API key cannot access this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found - Website does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/facts/search": {
      "get": {
        "tags": ["Knowledge Base"],
        "summary": "Search Brand Facts",
        "description": "Semantic search over a website's approved brand facts. Combines vector similarity with full-text search, so it also reaches facts not filed under any pillar. It searches only facts the Knowledge Base shows; facts generated by Oracle analysis are excluded. Returns fact text with confidence, source URL and quote, and the published pillar it belongs to (null when unfiled). Also available as the MCP tool `search_brand_facts`.",
        "operationId": "searchBrandFacts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The website whose Knowledge Base to read."
          },
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "description": "Natural-language search query."
          },
          {
            "name": "pillar_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Restrict results to facts filed under this pillar."
          },
          {
            "name": "top_k",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            },
            "description": "Maximum number of facts to return."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with matching facts, best matches first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "facts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BrandFactSearchResult"
                      }
                    }
                  },
                  "required": ["facts"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "missing_query": {
                    "value": {
                      "error": "query is required"
                    }
                  },
                  "invalid_top_k": {
                    "value": {
                      "error": "top_k must be between 1 and 50"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/facts": {
      "get": {
        "tags": ["Knowledge Base"],
        "summary": "Get Brand Facts",
        "description": "Lists a website's brand facts, newest first, with offset paging. By default excludes facts generated by Oracle analysis; pass `include_oracle=true` to include them. Filter by pillar, review status (defaults to approved), source type, or `unfiled=true` for facts not under any published pillar. `unfiled` and `pillar_id` are mutually exclusive. Also available as the MCP tool `get_brand_facts`.",
        "operationId": "getBrandFacts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The website whose Knowledge Base to read."
          },
          {
            "name": "pillar_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Only facts filed under this pillar."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["approved", "pending", "rejected"],
              "default": "approved"
            },
            "description": "Review-status bucket to list."
          },
          {
            "name": "source_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["research", "response", "upload", "content_hub"]
            },
            "description": "Only facts that entered through this source."
          },
          {
            "name": "unfiled",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["true", "false"]
            },
            "description": "When \"true\", only facts not filed under any published pillar. Mutually exclusive with pillar_id."
          },
          {
            "name": "include_oracle",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["true", "false"]
            },
            "description": "When \"true\", facts generated by Oracle analysis are included in the listing. Defaults to \"false\" (excluded)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            },
            "description": "Page size."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "Rows to skip."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with one page of facts and the uncapped total",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "facts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BrandFact"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "description": "Total facts matching the filters, ignoring paging."
                    }
                  },
                  "required": ["facts", "total"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "exclusive_filters": {
                    "value": {
                      "error": "unfiled and pillar_id are mutually exclusive"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Knowledge Base"],
        "summary": "Add Brand Facts",
        "description": "Adds brand facts to a website's Knowledge Base in bulk (1-50 per call). Every fact runs the full ingestion pipeline \u2014 deduplication, approval gates, and pillar routing \u2014 and there is no way to force-approve: inputs are declarative (text, optional source URL, optional pillar pin) and the response reports one outcome per fact. Facts without a pillar_id are routed automatically and may land unfiled. A fact that facts already in the Knowledge Base say something similar to is not added: its outcome is `duplicate` and lists them under `matches`, and the response carries a `match_token`. Resolve them with a second call carrying the same facts, the `match_token`, one decision per listed match and `save_submitted`. Requires a website-admin API key. Also available as the MCP tool `add_brand_facts`.",
        "operationId": "addBrandFacts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website whose Knowledge Base to add facts to."
                  },
                  "facts": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "description": "The facts to ingest. No status or approval field exists \u2014 the pipeline decides.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "text": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000,
                          "description": "The fact statement."
                        },
                        "source_url": {
                          "type": "string",
                          "description": "URL backing the fact. The fact can auto-approve only when this URL is on one of the website's domains: its URL patterns plus pages and domains marked Owned on the Sources page. Any other URL leaves the fact pending human review. Facts without a URL can auto-approve."
                        },
                        "pillar_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Pin the fact to this pillar (must belong to the website). Omit to let the pipeline route it."
                        }
                      },
                      "required": ["text"]
                    }
                  },
                  "match_token": {
                    "type": "string",
                    "description": "Second call only: the `match_token` from a response that listed `matches`. Send it with the same facts that were not added, one decision per listed match and `save_submitted`."
                  },
                  "decisions": {
                    "type": "array",
                    "maxItems": 500,
                    "description": "Second call only: one decision for every fact listed under `matches`, and only those. `approve` keeps the fact: an approved fact stays approved (and is filed under the facts' pillar if it has none); a pending fact is approved only when the same approval rules as a new fact allow its text and source (a third-party source or a competitive claim keeps it pending). With `text`, the fact is replaced by that wording, whose status the same rules decide. `delete` rejects a pending fact or archives an approved one.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "claim_id": {
                          "type": "string",
                          "description": "The `id` of a listed match."
                        },
                        "action": {
                          "type": "string",
                          "enum": ["approve", "delete"]
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000,
                          "description": "With `approve`: replace the fact with this wording."
                        }
                      },
                      "required": ["claim_id", "action"]
                    }
                  },
                  "save_submitted": {
                    "type": "boolean",
                    "description": "Second call only: true adds the facts as written, without another similarity check, through the usual approval gates; false only applies the decisions. The decisions and the added facts are written together or not at all."
                  }
                },
                "required": ["website_id", "facts"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Facts ingested; one outcome per fact, aligned with the request by index",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outcomes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BrandFactIngestOutcome"
                      }
                    },
                    "match_token": {
                      "type": "string",
                      "description": "Present when any outcome lists `matches`. Send it back on the second call."
                    },
                    "resolved": {
                      "type": "object",
                      "description": "Present on a second call: the listed facts the decisions approved, the approved ones the approval rules kept pending (a fact given new wording has a new id), and the ones rejected or archived.",
                      "properties": {
                        "approved_fact_ids": {
                          "type": "array",
                          "items": { "type": "string" }
                        },
                        "pending_fact_ids": {
                          "type": "array",
                          "items": { "type": "string" }
                        },
                        "removed_fact_ids": {
                          "type": "array",
                          "items": { "type": "string" }
                        }
                      },
                      "required": [
                        "approved_fact_ids",
                        "pending_fact_ids",
                        "removed_fact_ids"
                      ]
                    }
                  },
                  "required": ["outcomes"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "empty_facts": {
                    "value": {
                      "error": "facts must contain at least one fact"
                    }
                  },
                  "foreign_pillar": {
                    "value": {
                      "error": "facts[1].pillar_id does not exist on this website"
                    }
                  },
                  "unsafe_source_url": {
                    "value": {
                      "error": "facts[0].source_url is not a valid URL"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/facts/{fact_id}": {
      "patch": {
        "tags": ["Knowledge Base"],
        "summary": "Update Brand Fact",
        "description": "Updates one brand fact's text, source URL, or confidence. Only provided fields change; pass source_url: \"\" to clear the stored source. Changing the text creates a new fact (new id) and archives the current one; the new fact keeps the current review status and is the fact returned. Source URL and confidence edits update the fact in place and re-match the source to the internal link bank. Review status never changes through this endpoint. Requires a website-admin API key. Also available as the MCP tool `update_brand_fact`.",
        "operationId": "updateBrandFact",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "fact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The fact to update."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website the fact belongs to."
                  },
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000,
                    "description": "New fact statement. Caps at 10000 characters, matching the in-app edit dialog (add_brand_facts caps new facts at 2000)."
                  },
                  "source_url": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "New source URL. An empty string clears the stored source URL."
                  },
                  "confidence": {
                    "type": "string",
                    "enum": ["high", "medium", "low"],
                    "description": "New confidence level."
                  }
                },
                "required": ["website_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated fact plus a pre-update snapshot of the editable fields",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fact": {
                      "$ref": "#/components/schemas/BrandFact"
                    },
                    "before": {
                      "type": "object",
                      "description": "Values of the editable fields before this update.",
                      "properties": {
                        "text": {
                          "type": "string"
                        },
                        "source_url": {
                          "type": ["string", "null"]
                        },
                        "confidence": {
                          "type": ["string", "null"],
                          "enum": ["high", "medium", "low", null]
                        }
                      },
                      "required": ["text", "source_url", "confidence"]
                    }
                  },
                  "required": ["fact", "before"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "blank_text": {
                    "value": {
                      "error": "text must not be blank"
                    }
                  },
                  "unsafe_source_url": {
                    "value": {
                      "error": "source_url is not a valid URL"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - No fact with this id on the website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "fact_not_found": {
                    "value": {
                      "error": "Fact not found"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - The fact cannot be replaced: it was captured from an AI response, is a hidden duplicate, is rejected, or another edit archived it first (fetch the fact again and retry against the live one). A text change on a fact that has already been replaced returns 404, since the addressed fact is archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "identical_fact": {
                    "value": {
                      "error": "An identical fact already exists"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/facts/delete": {
      "post": {
        "tags": ["Knowledge Base"],
        "summary": "Delete Brand Facts",
        "description": "Permanently deletes 1-50 brand facts from a website's Knowledge Base. There is no undo. Ids with no fact on the website are reported in not_found_ids instead of failing the call, so retries are idempotent. Requires a website-admin API key; on OAuth MCP connections the signed-in user must hold the admin role. Also available as the MCP tool `delete_brand_facts`.",
        "operationId": "deleteBrandFacts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website whose facts to delete."
                  },
                  "fact_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Facts to delete. A single delete is a one-element array."
                  }
                },
                "required": ["website_id", "fact_ids"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deletion report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [true]
                    },
                    "deleted_count": {
                      "type": "integer",
                      "description": "Facts actually deleted."
                    },
                    "not_found_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Requested ids with no fact on this website: already deleted or never existed."
                    }
                  },
                  "required": ["success", "deleted_count", "not_found_ids"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "empty_fact_ids": {
                    "value": {
                      "error": "factIds: fact_ids must contain at least one id"
                    }
                  },
                  "too_many_fact_ids": {
                    "value": {
                      "error": "factIds: fact_ids must contain at most 50 ids"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/facts/move": {
      "post": {
        "tags": ["Knowledge Base"],
        "summary": "Move Brand Facts",
        "description": "Files 1-50 brand facts under a published Knowledge Base pillar. Works for unfiled facts and re-files facts from other pillars. Review status never changes, and only approved facts under a published pillar feed content generation, so moving is what puts approved facts to work. Ids with no fact on the website are reported in not_found_ids instead of failing the call, so retries are idempotent. Requires a website-admin API key. Also available as the MCP tool `move_brand_facts`.",
        "operationId": "moveBrandFacts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website whose facts to move."
                  },
                  "pillar_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The published pillar to file the facts under."
                  },
                  "fact_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Facts to move. A single move is a one-element array."
                  }
                },
                "required": ["website_id", "pillar_id", "fact_ids"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Move report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [true]
                    },
                    "moved_count": {
                      "type": "integer",
                      "description": "Facts actually re-filed onto the pillar."
                    },
                    "unchanged_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Requested facts that were not moved: already on the target, or no longer present by the time the move ran."
                    },
                    "not_found_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Requested ids with no fact on this website: already deleted or never existed."
                    },
                    "pillar": {
                      "type": "object",
                      "description": "The target pillar the facts were filed under.",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      },
                      "required": ["id", "name"]
                    }
                  },
                  "required": [
                    "success",
                    "moved_count",
                    "unchanged_ids",
                    "not_found_ids",
                    "pillar"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters, or the target pillar is not published",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "empty_fact_ids": {
                    "value": {
                      "error": "factIds: fact_ids must contain at least one id"
                    }
                  },
                  "too_many_fact_ids": {
                    "value": {
                      "error": "factIds: fact_ids must contain at most 50 ids"
                    }
                  },
                  "unpublished_pillar": {
                    "value": {
                      "error": "facts can only be moved to a published pillar"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - No pillar with this id on the website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "pillar_not_found": {
                    "value": {
                      "error": "Pillar not found"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/pillars": {
      "get": {
        "tags": ["Knowledge Base"],
        "summary": "Get Pillars",
        "description": "Lists a website's Knowledge Base pillars (excluding archived ones) with approved-fact counts, whether a synthesized document exists, and when each pillar was last researched. Also available as the MCP tool `get_pillars`.",
        "operationId": "getPillars",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The website whose Knowledge Base to read."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the website's pillars, sorted by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pillars": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KnowledgeBasePillar"
                      }
                    }
                  },
                  "required": ["pillars"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Knowledge Base"],
        "summary": "Create Pillar",
        "description": "Creates a Knowledge Base pillar (a subject area that groups brand facts) from a name and optional description. Get-or-create semantics: if a pillar with the same name already exists (case-insensitive), it is returned with `created: false` instead of failing, so retries and re-imports are idempotent. Requires a website-admin API key. Also available as the MCP tool `create_pillar`.",
        "operationId": "createPillar",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website to create the pillar on."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "Pillar name."
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "What the pillar covers."
                  }
                },
                "required": ["website_id", "name"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created (or pre-existing) pillar",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pillar": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": ["string", "null"]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "researching",
                            "published",
                            "draft",
                            "archived"
                          ]
                        }
                      },
                      "required": ["id", "name", "description", "status"]
                    },
                    "created": {
                      "type": "boolean",
                      "description": "False when a pillar with the same name already existed and was returned instead."
                    }
                  },
                  "required": ["pillar", "created"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  },
                  "missing_name": {
                    "value": {
                      "error": "name is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/pillars/{pillar_id}": {
      "patch": {
        "tags": ["Knowledge Base"],
        "summary": "Update Pillar",
        "description": "Updates a Knowledge Base pillar's name, description, or status. At least one of the three must be provided; only provided fields change. Renaming returns a 409 when another pillar already uses the name. Status accepts published or archived: archiving hides the pillar from pillar listings and stops its facts feeding content generation, while keeping the facts stored. Requires a website-admin API key. Also available as the MCP tool `update_pillar`.",
        "operationId": "updatePillar",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "pillar_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The pillar to update."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website the pillar belongs to."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "New pillar name."
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "New pillar description. An empty string clears the stored description."
                  },
                  "status": {
                    "type": "string",
                    "enum": ["published", "archived"],
                    "description": "New status. Only published and archived are accepted; the pipeline-internal states (draft, researching) cannot be set over the API."
                  }
                },
                "required": ["website_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated pillar plus a pre-update snapshot of the editable fields",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pillar": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": ["string", "null"]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "researching",
                            "published",
                            "draft",
                            "archived"
                          ]
                        }
                      },
                      "required": ["id", "name", "description", "status"]
                    },
                    "before": {
                      "type": "object",
                      "description": "Values of the editable fields before this update.",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": ["string", "null"]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "researching",
                            "published",
                            "draft",
                            "archived"
                          ]
                        }
                      },
                      "required": ["name", "description", "status"]
                    }
                  },
                  "required": ["pillar", "before"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters, or no editable field was provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "empty_edit": {
                    "value": {
                      "error": "at least one of name, description, or status is required"
                    }
                  },
                  "whitespace_name": {
                    "value": {
                      "error": "name cannot be empty"
                    }
                  },
                  "blank_name": {
                    "value": {
                      "error": "name: name must not be empty"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - No pillar with this id on the website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "pillar_not_found": {
                    "value": {
                      "error": "Pillar not found"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Another pillar already uses the requested name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "name_taken": {
                    "value": {
                      "error": "A pillar named \"Pricing\" already exists"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/pillars/delete": {
      "post": {
        "tags": ["Knowledge Base"],
        "summary": "Delete Pillars",
        "description": "Permanently deletes 1-20 Knowledge Base pillars and every fact filed under them. Facts are deleted, not unfiled; there is no undo. Ids with no pillar on the website are reported in not_found_ids instead of failing the call, so retries are idempotent; ids in failed_ids are untouched and safe to retry. Requires a website-admin API key; on OAuth MCP connections the signed-in user must hold the admin role. Also available as the MCP tool `delete_pillars`.",
        "operationId": "deletePillars",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website whose pillars to delete."
                  },
                  "pillar_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Pillars to delete. A single delete is a one-element array."
                  }
                },
                "required": ["website_id", "pillar_ids"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deletion report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [true]
                    },
                    "deleted_pillars": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "fact_count": {
                            "type": "integer",
                            "description": "Facts hard-deleted with this pillar."
                          }
                        },
                        "required": ["id", "name", "fact_count"]
                      },
                      "description": "Pillars actually deleted. A deleted pillar cannot be re-fetched, so this is the caller's record of what was destroyed."
                    },
                    "not_found_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Requested ids with no pillar on this website: already deleted or never existed."
                    },
                    "failed_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Pillars whose delete errored. Each pillar deletes in its own transaction, so these are untouched and safe to retry."
                    }
                  },
                  "required": [
                    "success",
                    "deleted_pillars",
                    "not_found_ids",
                    "failed_ids"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "empty_pillar_ids": {
                    "value": {
                      "error": "pillarIds: pillar_ids must contain at least one id"
                    }
                  },
                  "too_many_pillar_ids": {
                    "value": {
                      "error": "pillarIds: pillar_ids must contain at most 20 ids"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/pillars/merge": {
      "post": {
        "tags": ["Knowledge Base"],
        "summary": "Merge Pillars",
        "description": "Merges 1-20 source pillars into a published target pillar: every fact on the sources (any review status) re-files onto the target, page links carry over keeping the stronger signal, and the source pillars are then deleted. The target must be a published pillar and must not appear among the sources. Unlike the other Knowledge Base writes, retries are strict: missing source ids are rejected rather than skipped, so re-read the pillars before retrying a failed merge. Requires a website-admin API key. Also available as the MCP tool `merge_pillars`.",
        "operationId": "mergePillars",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "website_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The website whose pillars to merge."
                  },
                  "target_pillar_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The published pillar that survives and receives the sources' facts."
                  },
                  "source_pillar_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Pillars to fold into the target. Deleted after the merge."
                  }
                },
                "required": [
                  "website_id",
                  "target_pillar_id",
                  "source_pillar_ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Merge report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [true]
                    },
                    "moved_fact_count": {
                      "type": "integer",
                      "description": "Facts re-filed from the sources onto the target."
                    },
                    "merged_pillars": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": ["id", "name"]
                      },
                      "description": "The deleted source pillars, in request order. A deleted pillar cannot be re-fetched, so this is the caller's record."
                    },
                    "pillar": {
                      "type": "object",
                      "description": "The surviving target pillar.",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      },
                      "required": ["id", "name"]
                    }
                  },
                  "required": [
                    "success",
                    "moved_fact_count",
                    "merged_pillars",
                    "pillar"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters, no source other than the target, or the target pillar is not published",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unpublished_target": {
                    "value": {
                      "error": "pillars can only be merged into a published pillar"
                    }
                  },
                  "source_is_target": {
                    "value": {
                      "error": "source_pillar_ids must not include the target"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No admin access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - The target or one of the sources does not exist on the website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "target_not_found": {
                    "value": {
                      "error": "Target pillar not found"
                    }
                  },
                  "sources_not_found": {
                    "value": {
                      "error": "One or more source pillars were not found"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/pillars/{pillar_id}/document": {
      "get": {
        "tags": ["Knowledge Base"],
        "summary": "Get Pillar Document",
        "description": "Fetches a pillar's synthesized markdown document. Returns `document: null` when the pillar exists but has no synthesized document yet (this is a 200, not a 404). Also available as the MCP tool `get_pillar_document`.",
        "operationId": "getPillarDocument",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "pillar_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The pillar whose document to fetch."
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The website whose Knowledge Base to read."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the pillar's synthesized document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pillar_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "type": "string"
                    },
                    "document": {
                      "type": ["string", "null"],
                      "description": "The synthesized markdown document, or null when none exists yet."
                    },
                    "generated_at": {
                      "type": ["string", "null"],
                      "description": "ISO 8601 timestamp of the document's last generation, or null."
                    }
                  },
                  "required": ["pillar_id", "name", "document", "generated_at"]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_website_id": {
                    "value": {
                      "error": "website_id is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - No access to this website, or the Knowledge Base is not enabled for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unauthorized_website": {
                    "value": {
                      "error": "Unauthorized access to this website"
                    }
                  },
                  "kb_not_enabled": {
                    "value": {
                      "error": "Knowledge Base is not enabled for this organization"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found - The pillar does not exist on this website",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PromptScheduleSelection": {
        "description": "Select one streaming schedule. Use the selection returned by GET /api/v1/prompt-schedules. Default includes all pre-cutover history and ad hoc runs; archived schedules retain results. The retired manual token is accepted as an alias of default. This field takes one schedule; a list returns 400.",
        "default": "default",
        "oneOf": [
          { "type": "string", "enum": ["default", "manual"] },
          { "type": "string", "format": "uuid" }
        ]
      },
      "Website": {
        "type": "object",
        "description": "A website resource in AthenaHQ",
        "required": ["id", "websiteName", "websiteUrl"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the website",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "websiteName": {
            "type": "string",
            "description": "Display name of the website",
            "example": "My Awesome Blog"
          },
          "websiteUrl": {
            "type": "string",
            "description": "The domain of the website (without protocol)",
            "example": "example.com"
          },
          "baseCountry": {
            "type": "string",
            "nullable": true,
            "description": "Country market this website targets, as set in the website's brand profile (the \"Base location\" setting). Distinguishes per-country websites that share a brand name. Websites that never chose a country carry the default `\"United States\"`, so treat that value as unconfirmed for sites that do not look US-based. A few legacy rows hold ISO codes (e.g. `\"US\"`) rather than full names. Not included on `?external_id=` lookup responses, which omit the field entirely.",
            "example": "United States"
          },
          "onboardingStep": {
            "type": "integer",
            "nullable": true,
            "description": "Current onboarding step for the website. Null indicates onboarding is complete.",
            "example": null
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "**Partner-only.** The partner-supplied identifier mapped to this website. Only present on responses to callers whose organization is flagged as a partner. Direct-customer responses omit the field entirely. `null` indicates no mapping exists for this website.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "CreateWebsiteRequest": {
        "type": "object",
        "description": "Request body for creating a new website",
        "required": ["url"],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The URL of the website to create. Protocol (http/https) and trailing slashes will be automatically removed. Email addresses and other URLs with a user name (`name@example.com`) are rejected with `400`.",
            "example": "https://example.com",
            "maxLength": 2048
          },
          "external_id": {
            "type": "string",
            "minLength": 1,
            "description": "**Partner-only.** An identifier from your own system to map to this Athena website. Accepted only when authenticating with an API key for an organization flagged as a partner. Sending this field as a direct customer returns `403 Forbidden`. Must be unique per resource type within your organization \u2014 duplicates return `409` with the existing resource in the payload.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "CreatedWebsite": {
        "type": "object",
        "description": "A newly created website resource",
        "required": ["id", "websiteUrl", "orgId", "onboardingStep"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the website",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "websiteUrl": {
            "type": "string",
            "description": "The cleaned URL of the website (without protocol or trailing slash)",
            "example": "example.com"
          },
          "orgId": {
            "type": "string",
            "format": "uuid",
            "description": "The organization ID the website belongs to",
            "example": "987e6543-e21b-12d3-a456-426614174000"
          },
          "onboardingStep": {
            "type": "integer",
            "description": "The current onboarding step (starts at 1)",
            "example": 1
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "**Partner-only.** Echoes the `external_id` from the create request if provided, or `null` if the partner did not supply one. Only present on responses to partner API keys \u2014 direct-customer responses omit the field.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "Prompt": {
        "type": "object",
        "description": "A prompt resource for AI-powered content generation",
        "required": [
          "id",
          "prompt",
          "status",
          "country",
          "countries",
          "tags",
          "prompt_type"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the prompt",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "prompt": {
            "type": "string",
            "description": "The prompt text used for content generation",
            "example": "How to optimize website performance"
          },
          "topic_name": {
            "type": "string",
            "nullable": true,
            "description": "The name of the topic category this prompt belongs to",
            "example": "Web Development"
          },
          "current_monthly_searches": {
            "type": "integer",
            "description": "Estimated monthly search volume for this prompt. The keyword-volume provider only measures volume above a floor of ~100/mo; prompts below that floor are returned as 100.",
            "example": 5400
          },
          "current_total_value": {
            "type": "number",
            "nullable": true,
            "description": "Estimated total monthly value for this prompt",
            "example": 1250.5
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"],
            "description": "Current status of the prompt",
            "example": "active"
          },
          "country": {
            "type": "string",
            "deprecated": true,
            "description": "Deprecated. Use `countries` instead. Returns the primary country if one is marked primary, otherwise the alphabetically first country. Falls back to `\"United States\"` when the prompt has no countries.",
            "example": "United States"
          },
          "countries": {
            "type": "array",
            "description": "All target countries for the prompt. The primary country (if any) is listed first; remaining countries follow in alphabetical order. Empty when the prompt has no countries assigned.",
            "items": {
              "type": "object",
              "required": ["country", "is_primary"],
              "properties": {
                "country": {
                  "type": "string",
                  "description": "Country name",
                  "example": "United States"
                },
                "is_primary": {
                  "type": "boolean",
                  "description": "Whether this is the prompt's primary country. At most one country per prompt is primary.",
                  "example": true
                }
              }
            },
            "example": [
              {
                "country": "United States",
                "is_primary": true
              },
              {
                "country": "Canada",
                "is_primary": false
              }
            ]
          },
          "tags": {
            "type": "array",
            "description": "Tags assigned to the prompt, sorted case-insensitively by name. Empty when the prompt has no tags. Tag IDs can be passed to the `prompt_tags` filter on this endpoint or to `tag_ids` on POST /api/v1/prompts. List a website's full tag catalog with GET /api/v1/prompt-tags.",
            "items": {
              "$ref": "#/components/schemas/PromptTag"
            },
            "example": [
              {
                "id": "223e4567-e89b-12d3-a456-426614174111",
                "name": "Caption Phones"
              }
            ]
          },
          "prompt_type": {
            "type": "string",
            "enum": ["branded", "non_branded"],
            "nullable": true,
            "description": "Whether Athena shows the prompt as Branded or Non-branded. Returned separately from `tags`, which lists only custom tags. Uses the same values as the `prompt_type` filter on the metrics endpoints. `null` when the prompt has no type. To set it, send `type` on POST /api/v1/prompts or PATCH /api/v1/prompts/{prompt_id}, where `high_intent` is Branded and `discovery` is Non-branded.",
            "example": "non_branded"
          }
        }
      },
      "Competitor": {
        "type": "object",
        "description": "A competitor resource in AthenaHQ",
        "required": ["id", "name", "url", "normalized_url", "identifiers"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the competitor",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "name": {
            "type": "string",
            "description": "Display name of the competitor",
            "example": "Competitor Inc"
          },
          "url": {
            "type": "string",
            "description": "The URL of the competitor website",
            "example": "competitor.com"
          },
          "normalized_url": {
            "type": "string",
            "description": "Normalized URL of the competitor website",
            "example": "competitor.com"
          },
          "identifiers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of identifiers associated with this competitor",
            "example": ["Competitor Inc", "competitor.com"]
          }
        }
      },
      "DiscoveredCompetitor": {
        "type": "object",
        "description": "A brand Athena found in the website's AI responses that the website does not track, as listed on the Competitors page's Discovered competitors tab. It has no ID: it cannot be used in `competitor_ids` filters or the metrics endpoints until the website tracks it.",
        "required": [
          "name",
          "domain",
          "mention_count",
          "response_count",
          "mention_rate",
          "first_seen_at",
          "last_seen_at"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the brand as AI responses mention it",
            "example": "Competitor Inc"
          },
          "domain": {
            "type": "string",
            "nullable": true,
            "description": "The brand's website domain, on a best-effort basis: it is read from AI responses and can be wrong. `null` when unknown.",
            "example": "competitor.com"
          },
          "mention_count": {
            "type": "integer",
            "description": "Number of mentions of the brand found in the analyzed responses",
            "example": 21
          },
          "response_count": {
            "type": "integer",
            "description": "Number of analyzed responses that mention the brand",
            "example": 18
          },
          "mention_rate": {
            "type": "number",
            "description": "Percentage (0-100) of the responses Athena analyzed for discovery that mention the brand. This is not the date-range mention rate the metrics endpoints return.",
            "example": 8.6
          },
          "first_seen_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the brand was first found in a response (UTC). `null` when unknown.",
            "example": "2026-09-03T14:02:11.000Z"
          },
          "last_seen_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the brand was last found in a response (UTC). `null` when unknown.",
            "example": "2026-09-10T09:40:52.000Z"
          }
        }
      },
      "Location": {
        "type": "object",
        "description": "A location resource in AthenaHQ",
        "required": ["id", "location"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the location",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "location": {
            "type": "string",
            "description": "The location name",
            "example": "United States"
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Error response object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string",
            "description": "Error message describing what went wrong",
            "example": "Unauthorized"
          }
        }
      },
      "ExternalIdConflictError": {
        "type": "object",
        "description": "Returned when a partner tries to set an `external_id` that is already mapped to another resource of the same type within the organization. The `existing` field identifies the resource that currently holds the ID, letting the partner recover from a retry or reconcile their mapping.",
        "required": ["error", "message", "existing"],
        "properties": {
          "error": {
            "type": "string",
            "enum": ["external_id_conflict"],
            "description": "Machine-readable error code. Always `external_id_conflict`.",
            "example": "external_id_conflict"
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation of the conflict.",
            "example": "external_id ws_a7f3b2c9 is already mapped to a website"
          },
          "existing": {
            "type": "object",
            "required": ["id", "externalId"],
            "description": "The resource that currently holds the conflicting `external_id`.",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "Athena ID of the existing resource.",
                "example": "123e4567-e89b-12d3-a456-426614174000"
              },
              "externalId": {
                "type": "string",
                "description": "The external_id that is already mapped.",
                "example": "ws_a7f3b2c9"
              }
            }
          }
        }
      },
      "ProvisionWebsiteRequest": {
        "type": "object",
        "description": "Request body for provisioning a fully configured website",
        "required": ["url", "name"],
        "properties": {
          "url": {
            "type": "string",
            "description": "Website URL. Protocol (https://) is stripped automatically. Email addresses and other URLs with a user name (`name@example.com`) are rejected with `400`.",
            "example": "acme.com",
            "maxLength": 2048
          },
          "name": {
            "type": "string",
            "description": "Brand name",
            "example": "Acme Corp",
            "maxLength": 255
          },
          "description": {
            "type": "string",
            "description": "Brand description",
            "default": "",
            "example": "Enterprise widgets company"
          },
          "country": {
            "type": "string",
            "description": "Base country for the website",
            "default": "United States",
            "example": "United States"
          },
          "language": {
            "type": "string",
            "description": "Default language. If omitted, derived from country (e.g., Germany \u2192 German). Falls back to English.",
            "example": "English"
          },
          "industry": {
            "type": "string",
            "description": "Industry category. Common values: `SaaS & Software`, `E-commerce & Retail`, `Healthcare & Medical`, `Information Technology`, `Banking & Financial Services`, `Education & E-learning`, `Consulting`, `Manufacturing`, `Hospitality & Travel`, `Real Estate`, and more. Accepts any string.",
            "example": "SaaS & Software"
          },
          "identifiers": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500
            },
            "description": "Brand names, aliases, and abbreviations used for mention detection. If empty, auto-generated by AI on the first processing run.",
            "default": [],
            "example": ["Acme", "Acme Corp"],
            "maxItems": 200
          },
          "competitors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompetitorInput"
            },
            "description": "Competitors to track. Deduplicated by URL. Entries on the website's own URL, or a path under it, are skipped.",
            "default": [],
            "maxItems": 500
          },
          "prompts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromptInput"
            },
            "description": "Prompts (queries) to monitor across AI models. Deduplicated by text.",
            "default": [],
            "maxItems": 10000
          },
          "schedule": {
            "$ref": "#/components/schemas/ScheduleInput"
          },
          "external_id": {
            "type": "string",
            "minLength": 1,
            "description": "**Partner-only.** An identifier from your own system to map to this Athena website. Accepted only when authenticating with an API key for an organization flagged as a partner. Sending this field as a direct customer returns `403 Forbidden`. Must be unique per resource type within your organization \u2014 duplicates return `409` with the existing resource in the payload.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "CompetitorInput": {
        "type": "object",
        "description": "A competitor to track",
        "required": ["name", "url"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Competitor name",
            "example": "WidgetCo",
            "maxLength": 255
          },
          "url": {
            "type": "string",
            "description": "Competitor website URL",
            "example": "widgetco.com",
            "maxLength": 2048
          },
          "identifiers": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500
            },
            "description": "Additional aliases beyond the name and domain (which are included automatically). If empty, auto-generated on the first processing run.",
            "default": [],
            "example": ["WidgetCo"],
            "maxItems": 200
          }
        }
      },
      "PromptInput": {
        "type": "object",
        "description": "A prompt (query) to monitor across AI models",
        "required": ["text"],
        "properties": {
          "text": {
            "type": "string",
            "description": "The prompt/query text to send to AI models",
            "example": "best widget software",
            "maxLength": 2000
          },
          "topic": {
            "type": "string",
            "description": "Topic name to group the prompt under. Created if it doesn't exist. Omit it to leave the prompt uncategorized.",
            "example": "Products"
          },
          "type": {
            "type": "string",
            "enum": ["discovery", "high_intent"],
            "description": "Prompt type. `discovery` for informational queries, `high_intent` for purchase-intent queries.",
            "default": "discovery",
            "example": "discovery"
          }
        }
      },
      "ScheduleInput": {
        "type": "object",
        "description": "Processing schedule configuration. If omitted entirely, no schedule is created \u2014 the user can configure one via the UI. All fields within the schedule are optional with sensible defaults.",
        "properties": {
          "days": {
            "type": "object",
            "description": "Which days to run processing. Keys are day names (Monday\u2013Sunday), values are booleans.",
            "additionalProperties": {
              "type": "boolean"
            },
            "default": {
              "Monday": true,
              "Tuesday": true,
              "Wednesday": true,
              "Thursday": true,
              "Friday": true,
              "Saturday": true,
              "Sunday": true
            },
            "example": {
              "Monday": true,
              "Wednesday": true,
              "Friday": true
            }
          },
          "models": {
            "type": "object",
            "description": "Which AI models to query. Available model IDs: `chatgpt`, `ai_overview`, `perplexity`, `gemini`, `copilot`, `grok`, `ai_mode`, `claude`.",
            "additionalProperties": {
              "type": "boolean"
            },
            "default": {
              "chatgpt": true,
              "gemini": true,
              "copilot": true,
              "perplexity": true,
              "ai_overview": true
            },
            "example": {
              "chatgpt": true,
              "gemini": true,
              "perplexity": true
            }
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether automatic scheduled runs are enabled",
            "default": true
          },
          "processingHour": {
            "type": "integer",
            "minimum": 0,
            "maximum": 23,
            "description": "UTC hour when scheduled processing fires. If omitted, assigned randomly between 0\u201317."
          }
        }
      },
      "ProvisionedWebsite": {
        "type": "object",
        "description": "The provisioned website response",
        "required": [
          "id",
          "url",
          "name",
          "orgId",
          "promptCount",
          "competitorCount",
          "hasSchedule"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique website identifier",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "url": {
            "type": "string",
            "description": "Cleaned website URL (protocol stripped)",
            "example": "acme.com"
          },
          "name": {
            "type": "string",
            "description": "Brand name",
            "example": "Acme Corp"
          },
          "orgId": {
            "type": "string",
            "format": "uuid",
            "description": "Organization ID the website belongs to",
            "example": "987e6543-e21b-12d3-a456-426614174000"
          },
          "promptCount": {
            "type": "integer",
            "description": "Number of prompts created",
            "example": 2
          },
          "competitorCount": {
            "type": "integer",
            "description": "Number of competitors created",
            "example": 1
          },
          "hasSchedule": {
            "type": "boolean",
            "description": "Whether a processing schedule was configured",
            "example": true
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "**Partner-only.** Echoes the `external_id` from the provision request if provided, or `null` if the partner did not supply one. Only present on responses to partner API keys \u2014 direct-customer responses omit the field.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "CreditsResponse": {
        "type": "object",
        "description": "Credit balance response",
        "required": ["credits"],
        "properties": {
          "credits": {
            "type": "object",
            "required": ["total", "monthly", "one_off"],
            "properties": {
              "total": {
                "type": "integer",
                "description": "Total credit balance (monthly + one-off)",
                "example": 700
              },
              "monthly": {
                "type": "object",
                "description": "Monthly recurring credits",
                "required": ["balance", "next_reset_at"],
                "properties": {
                  "balance": {
                    "type": "integer",
                    "description": "Current monthly credit balance",
                    "example": 700
                  },
                  "next_reset_at": {
                    "type": "integer",
                    "description": "Timestamp in milliseconds when monthly credits will reset",
                    "example": 1772227690021
                  }
                }
              },
              "one_off": {
                "type": "object",
                "description": "One-off purchased credits",
                "required": ["balance"],
                "properties": {
                  "balance": {
                    "type": "integer",
                    "description": "Current one-off credit balance",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      },
      "ApiFilters": {
        "type": "object",
        "description": "Filters for querying responses and metrics. Pass location filters in the JSON body as `filters.location_ids`.",
        "required": ["start_date"],
        "properties": {
          "schedule_id": {
            "$ref": "#/components/schemas/PromptScheduleSelection"
          },
          "start_date": {
            "type": "string",
            "format": "date-time",
            "description": "Filter start date (UTC)",
            "example": "2024-01-01T00:00:00.000Z"
          },
          "end_date": {
            "type": "string",
            "format": "date-time",
            "description": "Filter end date (UTC)",
            "example": "2024-12-31T23:59:59.999Z"
          },
          "models": {
            "type": "array",
            "description": "Filter by AI models",
            "items": {
              "type": "string",
              "enum": [
                "chatgpt",
                "perplexity",
                "gemini",
                "google_ai_overview",
                "copilot",
                "claude",
                "ai_mode",
                "grok",
                "deepseek",
                "meta_ai",
                "mistral"
              ]
            },
            "example": ["chatgpt", "perplexity"]
          },
          "prompt_ids": {
            "type": "array",
            "description": "Filter by specific prompt IDs",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "competitor_ids": {
            "type": "array",
            "description": "Filter by specific competitor IDs",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "location_ids": {
            "type": "array",
            "description": "Filter by location IDs. Pass this in the JSON body as `filters.location_ids`, even when filtering by a single location. Use IDs returned by `GET /api/v1/locations`.",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "example": ["123e4567-e89b-12d3-a456-426614174111"]
          },
          "prompt_status": {
            "type": "string",
            "enum": ["active", "paused"],
            "description": "Filter by prompt status"
          },
          "prompt_type": {
            "type": "string",
            "enum": ["branded", "non_branded"],
            "description": "Filter by prompt type"
          }
        }
      },
      "ResponsesApiFilters": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ApiFilters"
          },
          {
            "type": "object",
            "description": "Additional filters supported only by the responses endpoint.",
            "properties": {
              "has_search_queries": {
                "type": "boolean",
                "description": "Filter by whether the model used at least one non-empty web or map search query."
              },
              "search_query_text": {
                "type": "string",
                "description": "Case-insensitive text to match within the web or map search queries used for a response."
              },
              "search_query_text_operator": {
                "type": "string",
                "enum": ["contains", "does_not_contain"],
                "default": "contains",
                "description": "How search_query_text matches."
              }
            }
          }
        ]
      },
      "MetricsApiFilters": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ApiFilters"
          },
          {
            "type": "object",
            "description": "Filters for the metrics endpoints: the shared response filters plus an optional saved view.",
            "properties": {
              "saved_view_id": {
                "type": "string",
                "format": "uuid",
                "description": "A saved view to apply, from `GET /api/v1/saved-views`. Its filters apply the way the dashboard applies them, including the dashboard's defaults of active prompts and every model. Any filter you also send replaces the view's value for that field. The view's saved date range is ignored: `start_date` and `end_date` decide the window. Returns `404` when the view is not on `website_id`, and `400` naming any view filter the API cannot apply, which you can replace by sending that filter explicitly.",
                "example": "123e4567-e89b-12d3-a456-426614174222"
              }
            }
          }
        ]
      },
      "ResponsesRequest": {
        "type": "object",
        "description": "Request body for querying responses",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the website to query responses for",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "$ref": "#/components/schemas/ResponsesApiFilters"
          },
          "page_num": {
            "type": "integer",
            "minimum": 0,
            "default": 0,
            "description": "Page number for pagination (0-indexed)",
            "example": 0
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 40,
            "description": "Number of responses per page",
            "example": 40
          },
          "include_response": {
            "type": "boolean",
            "default": true,
            "description": "Include the full answer text on each row. Set to `false` to omit the `response` field entirely (the heaviest part of a row) when you only need which prompt and variation ran and how it scored.",
            "example": false
          },
          "compact_sources": {
            "type": "boolean",
            "default": false,
            "description": "Replace the per-source `sources` objects with `source_domains`, a deduped and alphabetically sorted list of cited root domains. Use when you need which domains were cited but not their exact URLs.",
            "example": false
          }
        }
      },
      "Source": {
        "type": "object",
        "description": "A source cited in an AI response",
        "required": ["url", "root_domain"],
        "properties": {
          "url": {
            "type": "string",
            "description": "The source URL",
            "example": "example.com/article"
          },
          "normalized_url": {
            "type": "string",
            "nullable": true,
            "description": "Normalized version of the URL",
            "example": "example.com/article"
          },
          "root_domain": {
            "type": "string",
            "description": "Root domain of the source",
            "example": "example.com"
          },
          "suffix": {
            "type": "string",
            "nullable": true,
            "description": "Domain suffix",
            "example": ".com"
          }
        }
      },
      "ResponseCompetitor": {
        "type": "object",
        "description": "A competitor mentioned in an AI response",
        "required": ["id", "name", "url", "position"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Competitor ID",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "name": {
            "type": "string",
            "description": "Competitor name",
            "example": "Competitor Inc"
          },
          "url": {
            "type": "string",
            "description": "Competitor URL",
            "example": "competitor.com"
          },
          "position": {
            "type": "integer",
            "description": "Position/rank of competitor mention in the response",
            "example": 1
          }
        }
      },
      "Response": {
        "type": "object",
        "description": "An AI model response",
        "required": [
          "schedule",
          "id",
          "website_id",
          "prompt_id",
          "base_prompt",
          "prompt",
          "model",
          "mentioned",
          "cited",
          "created_at",
          "competitors"
        ],
        "properties": {
          "schedule": {
            "description": "Streaming schedule provenance: default (including legacy history and ad hoc runs), or a custom/archived schedule UUID. Uses the catalog selection value, not a stock schedule UUID.",
            "oneOf": [
              { "type": "string", "enum": ["default"] },
              { "type": "string", "format": "uuid" }
            ],
            "example": "default"
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the response",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "Associated website ID",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "prompt_id": {
            "type": "string",
            "format": "uuid",
            "description": "Associated prompt ID",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "base_prompt": {
            "type": "string",
            "description": "Original prompt text",
            "example": "What is the best CRM software?"
          },
          "prompt": {
            "type": "string",
            "description": "Actual prompt variation used",
            "example": "What is the best CRM software for small businesses?"
          },
          "model": {
            "type": "string",
            "description": "AI model that generated the response",
            "example": "chatgpt"
          },
          "response": {
            "type": "string",
            "description": "The AI-generated response text. Omitted when `include_response` is `false`.",
            "example": "Here are some top CRM options..."
          },
          "mentioned": {
            "type": "boolean",
            "description": "Whether your website was mentioned in the response",
            "example": true
          },
          "position": {
            "type": "integer",
            "nullable": true,
            "description": "Your website's rank/position in the response (null if not mentioned)",
            "example": 2
          },
          "cited": {
            "type": "boolean",
            "description": "Whether your website was cited as a source",
            "example": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp when the response was captured (UTC)",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "sources": {
            "type": "array",
            "description": "Sources cited in the response. Omitted when `compact_sources` is `true`; `source_domains` takes its place.",
            "items": {
              "$ref": "#/components/schemas/Source"
            }
          },
          "source_domains": {
            "type": "array",
            "description": "Deduped, alphabetically sorted root domains cited in the response. Hosts are lower-cased with any leading `www.` removed; subdomains are preserved, so `shop.example.com` stays distinct from `example.com`. Present only when `compact_sources` is `true`.",
            "items": {
              "type": "string"
            },
            "example": ["example.com", "runnersworld.com"]
          },
          "competitors": {
            "type": "array",
            "description": "Competitors mentioned in the response",
            "items": {
              "$ref": "#/components/schemas/ResponseCompetitor"
            }
          }
        }
      },
      "CumulativeSOVEntry": {
        "type": "object",
        "description": "A share of voice entry showing brand/competitor visibility",
        "required": [
          "name",
          "value",
          "relative_mention_rate",
          "absolute_value",
          "is_self"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Brand or competitor name",
            "example": "Acme Corp"
          },
          "value": {
            "type": "number",
            "description": "Share of voice percentage (0-100)",
            "example": 33.3
          },
          "relative_mention_rate": {
            "type": "number",
            "description": "Relative mention rate percentage (0-100): mentions of this brand/competitor divided by the number of responses that mention at least one tracked brand",
            "example": 40
          },
          "absolute_value": {
            "type": "integer",
            "description": "Raw mention count",
            "example": 150
          },
          "is_self": {
            "type": "boolean",
            "description": "True if this entry represents your tracked website",
            "example": true
          }
        }
      },
      "TimeSeriesSOVEntry": {
        "type": "object",
        "description": "Daily share of voice data point",
        "required": ["date"],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "Date in YYYY-MM-DD format",
            "example": "2024-06-15"
          }
        },
        "additionalProperties": {
          "type": "object",
          "description": "Company name as key with SOV data as value",
          "required": ["value", "relative_mention_rate", "is_self"],
          "properties": {
            "value": {
              "type": "number",
              "description": "Share of voice percentage for this day"
            },
            "relative_mention_rate": {
              "type": "number",
              "description": "Relative mention rate percentage (0-100) for this day: mentions of this brand/competitor divided by the number of responses that mention at least one tracked brand"
            },
            "is_self": {
              "type": "boolean",
              "description": "True if this is your tracked website"
            }
          }
        }
      },
      "SOVRequest": {
        "type": "object",
        "description": "Request body for share of voice endpoints",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the website to query share of voice for",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "$ref": "#/components/schemas/MetricsApiFilters"
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z",
            "location_ids": ["123e4567-e89b-12d3-a456-426614174111"]
          }
        }
      },
      "PositionRequest": {
        "type": "object",
        "description": "Request body for position endpoints",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the website to query position metrics for",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "$ref": "#/components/schemas/MetricsApiFilters"
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z",
            "location_ids": ["123e4567-e89b-12d3-a456-426614174111"]
          }
        }
      },
      "CumulativePositionEntry": {
        "type": "object",
        "description": "Position data for a brand or competitor",
        "properties": {
          "avg_position": {
            "type": "number",
            "description": "Average position/rank in AI responses",
            "example": 2.5
          },
          "is_self": {
            "type": "boolean",
            "description": "True if this entry represents your tracked website",
            "example": true
          }
        }
      },
      "TimeSeriesPositionEntry": {
        "type": "object",
        "description": "Daily position data point",
        "additionalProperties": {
          "type": "object",
          "description": "Company name as key with position data as value",
          "properties": {
            "percentile_ranking": {
              "type": "number",
              "description": "Percentile ranking for this day"
            },
            "avg_position": {
              "type": "number",
              "description": "Average position for this day"
            },
            "is_self": {
              "type": "boolean",
              "description": "True if this is your tracked website"
            }
          }
        }
      },
      "MentionRateRequest": {
        "type": "object",
        "description": "Request body for mention rate endpoints",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the website to query mention rates for",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "$ref": "#/components/schemas/MetricsApiFilters"
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z",
            "location_ids": ["123e4567-e89b-12d3-a456-426614174111"]
          }
        }
      },
      "CumulativeMentionRateEntry": {
        "type": "object",
        "description": "Mention rate data for a brand or competitor",
        "required": ["mention_rate", "relative_mention_rate", "is_self"],
        "properties": {
          "mention_rate": {
            "type": "number",
            "description": "Absolute mention rate percentage (0-100): mentions divided by all responses",
            "example": 45.5
          },
          "relative_mention_rate": {
            "type": "number",
            "description": "Relative mention rate percentage (0-100): mentions divided by the number of responses that mention at least one tracked brand",
            "example": 61.1
          },
          "is_self": {
            "type": "boolean",
            "description": "True if this entry represents your tracked website",
            "example": true
          }
        }
      },
      "TimeSeriesMentionRateEntry": {
        "type": "object",
        "description": "Daily mention rate data point",
        "required": ["date", "metrics"],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "Date in YYYY-MM-DD format",
            "example": "2024-06-15"
          },
          "metrics": {
            "type": "object",
            "description": "Company names as keys with mention rate data as values",
            "additionalProperties": {
              "type": "object",
              "required": ["mention_rate", "relative_mention_rate", "is_self"],
              "properties": {
                "mention_rate": {
                  "type": "number",
                  "description": "Absolute mention rate percentage for this day: mentions divided by all responses"
                },
                "relative_mention_rate": {
                  "type": "number",
                  "description": "Relative mention rate percentage (0-100) for this day: mentions divided by the number of responses that mention at least one tracked brand"
                },
                "is_self": {
                  "type": "boolean",
                  "description": "True if this is your tracked website"
                }
              }
            }
          }
        }
      },
      "CitationRateRequest": {
        "type": "object",
        "description": "Request body for citation rate endpoints",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the website to query citation rates for",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "$ref": "#/components/schemas/MetricsApiFilters"
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z",
            "location_ids": ["123e4567-e89b-12d3-a456-426614174111"]
          }
        }
      },
      "CumulativeCitationRateEntry": {
        "type": "object",
        "description": "Citation rate data for a brand or competitor",
        "properties": {
          "citation_rate": {
            "type": "number",
            "description": "Absolute citation rate percentage (0-100): cited responses divided by all responses",
            "example": 28.5
          },
          "relative_citation_rate": {
            "type": "number",
            "description": "Relative citation rate percentage (0-100): cited responses divided by the number of responses that cite your brand or at least one tracked competitor",
            "example": 52.3
          },
          "is_self": {
            "type": "boolean",
            "description": "True if this entry represents your tracked website",
            "example": true
          }
        }
      },
      "TimeSeriesCitationRateEntry": {
        "type": "object",
        "description": "Daily citation rate data point",
        "required": ["date", "metrics"],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "Date in YYYY-MM-DD format",
            "example": "2024-06-15"
          },
          "metrics": {
            "type": "object",
            "description": "Company names as keys with citation rate data as values",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "citation_rate": {
                  "type": "number",
                  "description": "Citation rate percentage for this day"
                },
                "relative_citation_rate": {
                  "type": "number",
                  "description": "Citation rate percentage for this day, out of the responses that cite your brand or at least one tracked competitor"
                },
                "is_self": {
                  "type": "boolean",
                  "description": "True if this is your tracked website"
                }
              }
            }
          }
        }
      },
      "ShoppingMetricsFilters": {
        "type": "object",
        "description": "Filters for the shopping metrics endpoint. Only the filters the Shopping Insights page applies are accepted; any other filter key is rejected with 400.",
        "required": ["start_date"],
        "properties": {
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "Start of the date range, YYYY-MM-DD (UTC), inclusive",
            "example": "2026-08-01"
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "End of the date range, YYYY-MM-DD (UTC), inclusive. Defaults to today. Must be on or after start_date.",
            "example": "2026-08-31"
          },
          "schedule_id": {
            "$ref": "#/components/schemas/PromptScheduleSelection"
          },
          "models": {
            "type": "array",
            "description": "Shopping-capable models to include. Omit for all.",
            "items": {
              "type": "string",
              "enum": ["chatgpt", "ai_mode", "gemini", "perplexity", "copilot"]
            },
            "example": ["chatgpt"]
          },
          "competitor_ids": {
            "type": "array",
            "description": "Competitor UUIDs to keep in the competitor blocks. Own products are always included. Omit for all competitors.",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "prompt_tags": {
            "type": "array",
            "description": "Prompt tag IDs to filter prompts by (list tags with GET /api/v1/prompt-tags). Omit for all tags.",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "prompt_tags_operator": {
            "type": "string",
            "enum": ["is_any_of", "has_all_of"],
            "description": "How prompt_tags combine: is_any_of matches prompts with any listed tag, has_all_of only prompts carrying every listed tag. Defaults to is_any_of."
          },
          "target_identifiers": {
            "type": "array",
            "description": "Target identifier strings to filter responses to. The literal string no-identifier selects responses with no target identifier. Omit for all.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ShoppingMetricsRequest": {
        "type": "object",
        "description": "Request body for the shopping metrics endpoint",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the website to query shopping metrics for",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "$ref": "#/components/schemas/ShoppingMetricsFilters"
          },
          "top_products_limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50,
            "default": 10,
            "description": "How many products to return in each of top_own_products and top_competitor_products"
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2026-08-01",
            "end_date": "2026-08-31",
            "models": ["chatgpt"]
          },
          "top_products_limit": 10
        }
      },
      "ShoppingProduct": {
        "type": "object",
        "required": [
          "title",
          "merchant",
          "appearances",
          "avg_position",
          "avg_rating",
          "image_url",
          "product_url"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "Product title as shown in the shopping answer",
            "example": "Acme Trail Runner 3"
          },
          "merchant": {
            "type": ["string", "null"],
            "description": "Retailer the product was listed from, when the answer named one",
            "example": "Amazon"
          },
          "appearances": {
            "type": "integer",
            "description": "Number of shopping answers the product appeared in",
            "example": 25
          },
          "avg_position": {
            "type": ["number", "null"],
            "description": "Average 1-based position in the carousel (lower is better); null when no appearance carried a position",
            "example": 1.5
          },
          "avg_rating": {
            "type": ["number", "null"],
            "description": "Average rating shown for the product, when any",
            "example": 4.5
          },
          "image_url": {
            "type": ["string", "null"],
            "description": "Product image URL from the answer",
            "example": "https://example.com/trail-runner.jpg"
          },
          "product_url": {
            "type": ["string", "null"],
            "description": "Product page URL from the answer",
            "example": "https://example.com/products/trail-runner-3"
          }
        }
      },
      "ShoppingCompetitorProduct": {
        "type": "object",
        "required": [
          "title",
          "merchant",
          "appearances",
          "avg_position",
          "avg_rating",
          "image_url",
          "product_url",
          "competitor_id"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "Product title as shown in the shopping answer",
            "example": "Acme Trail Runner 3"
          },
          "merchant": {
            "type": ["string", "null"],
            "description": "Retailer the product was listed from, when the answer named one",
            "example": "Amazon"
          },
          "appearances": {
            "type": "integer",
            "description": "Number of shopping answers the product appeared in",
            "example": 25
          },
          "avg_position": {
            "type": ["number", "null"],
            "description": "Average 1-based position in the carousel (lower is better); null when no appearance carried a position",
            "example": 1.5
          },
          "avg_rating": {
            "type": ["number", "null"],
            "description": "Average rating shown for the product, when any",
            "example": 4.5
          },
          "image_url": {
            "type": ["string", "null"],
            "description": "Product image URL from the answer",
            "example": "https://example.com/trail-runner.jpg"
          },
          "product_url": {
            "type": ["string", "null"],
            "description": "Product page URL from the answer",
            "example": "https://example.com/products/trail-runner-3"
          },
          "competitor_id": {
            "type": ["string", "null"],
            "description": "Competitor the product was attributed to",
            "example": "123e4567-e89b-12d3-a456-426614174222"
          }
        }
      },
      "ShoppingMetricsData": {
        "type": "object",
        "description": "The Shopping Insights dashboard blocks. Rates are percentages 0-100; positions are 1-based (lower is better).",
        "required": [
          "summary",
          "offer_summary",
          "top_own_products",
          "top_competitor_products",
          "competitor_breakdown",
          "merchant_breakdown",
          "position_distribution",
          "price_comparison",
          "trend"
        ],
        "properties": {
          "summary": {
            "type": "object",
            "description": "Headline counts across every shopping answer in the range",
            "required": [
              "total_shopping_responses",
              "responses_with_own_products",
              "appearance_rate",
              "total_products",
              "own_products",
              "competitor_products",
              "avg_own_position",
              "avg_competitor_position"
            ],
            "properties": {
              "total_shopping_responses": {
                "type": "integer",
                "description": "Responses that included a product carousel",
                "example": 50
              },
              "responses_with_own_products": {
                "type": "integer",
                "description": "Shopping answers that included at least one of the brand's products",
                "example": 20
              },
              "appearance_rate": {
                "type": "number",
                "description": "responses_with_own_products / total_shopping_responses as a percentage 0-100",
                "example": 40
              },
              "total_products": {
                "type": "integer",
                "description": "Product appearances across all shopping answers",
                "example": 150
              },
              "own_products": {
                "type": "integer",
                "description": "Appearances of the brand's own products",
                "example": 40
              },
              "competitor_products": {
                "type": "integer",
                "description": "Appearances attributed to tracked competitors",
                "example": 110
              },
              "avg_own_position": {
                "type": ["number", "null"],
                "description": "Average carousel position of the brand's products",
                "example": 2.5
              },
              "avg_competitor_position": {
                "type": ["number", "null"],
                "description": "Average carousel position of competitor products",
                "example": 4.2
              }
            }
          },
          "offer_summary": {
            "type": "object",
            "description": "Retail offers (price listings) attached to the products in the range",
            "required": [
              "total_offers",
              "products_with_offers",
              "competitor_offers",
              "currency",
              "avg_price"
            ],
            "properties": {
              "total_offers": {
                "type": "integer",
                "description": "Offers attached to the brand's products",
                "example": 200
              },
              "products_with_offers": {
                "type": "integer",
                "description": "Brand product appearances that carried at least one offer",
                "example": 80
              },
              "competitor_offers": {
                "type": "integer",
                "description": "Offers attached to competitor products",
                "example": 60
              },
              "currency": {
                "type": "string",
                "description": "Currency of avg_price (the most common offer currency)",
                "example": "USD"
              },
              "avg_price": {
                "type": ["number", "null"],
                "description": "Average offer price of the brand's products",
                "example": 149.99
              }
            }
          },
          "top_own_products": {
            "type": "array",
            "description": "The brand's most frequently shown products, most appearances first",
            "items": {
              "$ref": "#/components/schemas/ShoppingProduct"
            }
          },
          "top_competitor_products": {
            "type": "array",
            "description": "Competitor products shown most often, most appearances first",
            "items": {
              "$ref": "#/components/schemas/ShoppingCompetitorProduct"
            }
          },
          "competitor_breakdown": {
            "type": "array",
            "description": "Competitor leaderboard: which tracked competitors show up most in shopping answers",
            "items": {
              "type": "object",
              "required": [
                "competitor_id",
                "competitor_name",
                "product_count",
                "avg_position",
                "avg_rating",
                "response_count"
              ],
              "properties": {
                "competitor_id": {
                  "type": "string",
                  "format": "uuid",
                  "example": "123e4567-e89b-12d3-a456-426614174222"
                },
                "competitor_name": {
                  "type": ["string", "null"],
                  "description": "Competitor name",
                  "example": "Rival Runners"
                },
                "product_count": {
                  "type": "integer",
                  "description": "Product appearances attributed to the competitor",
                  "example": 30
                },
                "avg_position": {
                  "type": ["number", "null"],
                  "description": "Average carousel position of the competitor's products; null when no appearance carried a position",
                  "example": 3.5
                },
                "avg_rating": {
                  "type": ["number", "null"],
                  "description": "Average rating shown for the competitor's products",
                  "example": 4.2
                },
                "response_count": {
                  "type": "integer",
                  "description": "Shopping answers the competitor appeared in",
                  "example": 15
                }
              }
            }
          },
          "merchant_breakdown": {
            "type": "array",
            "description": "Retailer breakdown: where products are stocked in AI answers, own versus competitor",
            "items": {
              "type": "object",
              "required": [
                "merchant",
                "own_count",
                "competitor_count",
                "own_avg_position",
                "competitor_avg_position",
                "own_response_count",
                "competitor_response_count"
              ],
              "properties": {
                "merchant": {
                  "type": "string",
                  "example": "Amazon"
                },
                "own_count": {
                  "type": "integer",
                  "description": "Brand product appearances listed from this retailer",
                  "example": 15
                },
                "competitor_count": {
                  "type": "integer",
                  "description": "Competitor product appearances listed from this retailer",
                  "example": 35
                },
                "own_avg_position": {
                  "type": ["number", "null"],
                  "description": "Average position of the brand's products from this retailer",
                  "example": 2.8
                },
                "competitor_avg_position": {
                  "type": ["number", "null"],
                  "description": "Average position of competitor products from this retailer",
                  "example": 3.6
                },
                "own_response_count": {
                  "type": "integer",
                  "description": "Shopping answers with a brand product from this retailer",
                  "example": 12
                },
                "competitor_response_count": {
                  "type": "integer",
                  "description": "Shopping answers with a competitor product from this retailer",
                  "example": 22
                }
              }
            }
          },
          "position_distribution": {
            "type": "array",
            "description": "Rank distribution: who occupies each carousel position",
            "items": {
              "type": "object",
              "required": [
                "position",
                "count",
                "own_count",
                "competitor_count"
              ],
              "properties": {
                "position": {
                  "type": "integer",
                  "description": "1-based carousel position",
                  "example": 1
                },
                "count": {
                  "type": "integer",
                  "description": "Product appearances at this position",
                  "example": 40
                },
                "own_count": {
                  "type": "integer",
                  "description": "Brand product appearances at this position",
                  "example": 12
                },
                "competitor_count": {
                  "type": "integer",
                  "description": "Competitor product appearances at this position",
                  "example": 28
                }
              }
            }
          },
          "price_comparison": {
            "type": "array",
            "description": "Offer price range for the brand's products versus competitors, per currency",
            "items": {
              "type": "object",
              "required": [
                "category",
                "currency",
                "avg_price",
                "min_price",
                "max_price",
                "product_count"
              ],
              "properties": {
                "category": {
                  "type": "string",
                  "enum": ["own", "competitor"]
                },
                "currency": {
                  "type": "string",
                  "example": "USD"
                },
                "avg_price": {
                  "type": ["number", "null"],
                  "description": "Average offer price",
                  "example": 149.99
                },
                "min_price": {
                  "type": ["number", "null"],
                  "description": "Lowest offer price",
                  "example": 89
                },
                "max_price": {
                  "type": ["number", "null"],
                  "description": "Highest offer price",
                  "example": 219
                },
                "product_count": {
                  "type": "integer",
                  "description": "Product appearances with a parseable price",
                  "example": 80
                }
              }
            }
          },
          "trend": {
            "type": "array",
            "description": "Daily product appearances, own versus competitor",
            "items": {
              "type": "object",
              "required": [
                "date",
                "total_products",
                "own_products",
                "competitor_products",
                "total_responses",
                "responses_with_own"
              ],
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date",
                  "example": "2026-08-01"
                },
                "total_products": {
                  "type": "integer",
                  "example": 5
                },
                "own_products": {
                  "type": "integer",
                  "example": 2
                },
                "competitor_products": {
                  "type": "integer",
                  "example": 3
                },
                "total_responses": {
                  "type": "integer",
                  "description": "Shopping answers that day",
                  "example": 4
                },
                "responses_with_own": {
                  "type": "integer",
                  "description": "Shopping answers that day with a brand product",
                  "example": 2
                }
              }
            }
          }
        }
      },
      "CreateInviteRequest": {
        "type": "object",
        "description": "Request body for creating an invite",
        "required": ["type", "invite_method", "email"],
        "properties": {
          "type": {
            "type": "string",
            "enum": ["organization", "website", "group"],
            "description": "The type of invite. 'organization' grants org-wide access, 'website' grants access to a single website, 'group' grants access to all websites in a group. Group invites require a global API key.",
            "example": "organization"
          },
          "invite_method": {
            "type": "string",
            "enum": ["direct", "email"],
            "description": "How to invite the user. 'direct' adds the user to the resource immediately without sending any email \u2014 if no account exists for the email, a new user account is created automatically (with emailVerified=false) and the membership is added. 'email' creates a pending invite record and sends an invitation email via Postmark; the user must accept the invite to gain access.",
            "example": "email"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Email address of the user to invite",
            "example": "user@example.com"
          },
          "role": {
            "type": "string",
            "enum": ["admin", "viewer"],
            "description": "The role to assign to the invited user. Mutually exclusive with `role_id`.",
            "example": "viewer"
          },
          "role_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
            "description": "Assign any role by ID \u2014 a system role or one of your organization's custom roles (see `GET /api/v1/roles`). Mutually exclusive with `role`. Returns 404 if the role does not exist or belongs to another organization. Defaults to Viewer when neither `role` nor `role_id` is given. System role IDs are GUID-shaped sentinels (e.g. `00000000-0000-0000-0000-000000000001`), not RFC 4122 UUIDs.",
            "example": "789e0123-e89b-12d3-a456-426614174000"
          },
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "Required when type is 'website'. The ID of the website to grant access to",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "group_id": {
            "type": "string",
            "format": "uuid",
            "description": "Required when type is 'group'. The ID of the group to grant access to. Requires a global API key.",
            "example": "456e7890-e89b-12d3-a456-426614174000"
          },
          "first_name": {
            "type": "string",
            "description": "Optional first name of the invited user. Used when creating a new user account for 'direct' invites or populating the invite record for 'email' invites.",
            "example": "John"
          },
          "last_name": {
            "type": "string",
            "description": "Optional last name of the invited user. Used when creating a new user account for 'direct' invites or populating the invite record for 'email' invites.",
            "example": "Doe"
          }
        }
      },
      "InviteResponse": {
        "type": "object",
        "description": "Response from creating an invite",
        "required": ["success", "message"],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the operation was successful",
            "example": true
          },
          "invite_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the created invite (only present for email invites)",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the user the invite targets. Present only for direct invites (the user is looked up or created immediately). Never returned for email-method invites to prevent cross-tenant account-existence enumeration.",
            "example": "abc12345-e89b-12d3-a456-426614174000"
          },
          "message": {
            "type": "string",
            "description": "A message describing the result",
            "example": "Invitation sent"
          }
        }
      },
      "BulkInviteRequest": {
        "type": "object",
        "description": "Request body for inviting a user to multiple websites or multiple groups. Provide exactly one of `website_ids` or `group_ids` \u2014 the two are mutually exclusive. A single consolidated invitation email is sent in 'email' mode.",
        "required": ["invite_method", "email"],
        "properties": {
          "invite_method": {
            "type": "string",
            "enum": ["direct", "email"],
            "description": "How to invite the user. 'direct' adds the user to each target immediately without sending any email \u2014 if no account exists for the email, a new user account is created automatically (with emailVerified=false). 'email' creates pending invite records and sends a single consolidated invitation email.",
            "example": "direct"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Email address of the user to invite",
            "example": "user@example.com"
          },
          "role": {
            "type": "string",
            "enum": ["admin", "viewer"],
            "description": "The role to assign to the invited user on each target. Mutually exclusive with `role_id`.",
            "example": "viewer"
          },
          "role_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
            "description": "Assign any role by ID \u2014 a system role or one of your organization's custom roles (see `GET /api/v1/roles`). Mutually exclusive with `role`. Returns 404 if the role does not exist or belongs to another organization. Defaults to Viewer when neither `role` nor `role_id` is given. System role IDs are GUID-shaped sentinels (e.g. `00000000-0000-0000-0000-000000000001`), not RFC 4122 UUIDs.",
            "example": "789e0123-e89b-12d3-a456-426614174000"
          },
          "website_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "minItems": 1,
            "maxItems": 50,
            "description": "Array of website IDs to invite the user to (1-50). Mutually exclusive with `group_ids`.",
            "example": [
              "123e4567-e89b-12d3-a456-426614174000",
              "987e6543-e21b-12d3-a456-426614174000"
            ]
          },
          "group_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "minItems": 1,
            "maxItems": 50,
            "description": "Array of group IDs to invite the user to (1-50). Mutually exclusive with `website_ids`. Requires a global API key.",
            "example": [
              "456e7890-e89b-12d3-a456-426614174000",
              "789e0123-e89b-12d3-a456-426614174000"
            ]
          },
          "first_name": {
            "type": "string",
            "description": "Optional first name of the invited user. Used when creating a new user account for 'direct' invites or populating invite records for 'email' invites.",
            "example": "John"
          },
          "last_name": {
            "type": "string",
            "description": "Optional last name of the invited user. Used when creating a new user account for 'direct' invites or populating invite records for 'email' invites.",
            "example": "Doe"
          }
        }
      },
      "BulkInviteResponse": {
        "type": "object",
        "description": "Response from a bulk invite request. Each target (website or group) is processed independently.",
        "required": ["success", "results"],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the bulk operation was processed (always true if request was valid)",
            "example": true
          },
          "results": {
            "type": "array",
            "description": "Per-target results (one entry per website or group in the request)",
            "items": {
              "$ref": "#/components/schemas/BulkInviteResult"
            }
          }
        }
      },
      "BulkInviteResult": {
        "type": "object",
        "description": "Result for a single target (website or group) in a bulk invite. Exactly one of `website_id` or `group_id` will be present, matching the field used in the request.",
        "required": ["success"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The website ID this result is for (present only when the request used `website_ids`)",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "group_id": {
            "type": "string",
            "format": "uuid",
            "description": "The group ID this result is for (present only when the request used `group_ids`)",
            "example": "456e7890-e89b-12d3-a456-426614174000"
          },
          "success": {
            "type": "boolean",
            "description": "Whether the invite was successful for this target"
          },
          "invite_id": {
            "type": "string",
            "format": "uuid",
            "description": "The invite ID (only present for successful email invites)"
          },
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the user the invite targets. Present only for successful direct invites. Never returned for email-method invites to prevent cross-tenant account-existence enumeration."
          },
          "message": {
            "type": "string",
            "description": "Success message (present when success is true)",
            "example": "User added to website"
          },
          "error": {
            "type": "string",
            "description": "Error message (present when success is false)",
            "example": "User is already a member of this website"
          }
        }
      },
      "SubscriptionProduct": {
        "type": "object",
        "description": "A subscription product associated with a website",
        "required": ["id", "name", "status"],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for the product",
            "example": "pro_monthly"
          },
          "name": {
            "type": "string",
            "description": "Display name of the product",
            "example": "Pro Plan"
          },
          "status": {
            "type": "string",
            "enum": ["active", "trialing", "expired", "canceled", "past_due"],
            "description": "Current status of the subscription",
            "example": "active"
          },
          "canceled_at": {
            "type": "integer",
            "nullable": true,
            "description": "Timestamp in milliseconds when the subscription was canceled (null if not canceled)",
            "example": null
          },
          "cancel_at": {
            "type": "integer",
            "nullable": true,
            "description": "Timestamp in milliseconds when the subscription will be canceled (null if not scheduled for cancellation)",
            "example": null
          },
          "started_at": {
            "type": "integer",
            "nullable": true,
            "description": "Timestamp in milliseconds when the subscription started",
            "example": 1704067200000
          },
          "ended_at": {
            "type": "integer",
            "nullable": true,
            "description": "Timestamp in milliseconds when the subscription ended (null if still active)",
            "example": null
          }
        }
      },
      "Group": {
        "type": "object",
        "description": "A group of websites in your organization",
        "required": [
          "id",
          "name",
          "orgId",
          "billingEnabled",
          "createdAt",
          "websites"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the group",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "name": {
            "type": "string",
            "description": "Display name of the group",
            "example": "Enterprise Clients"
          },
          "orgId": {
            "type": "string",
            "format": "uuid",
            "description": "The organization ID the group belongs to",
            "example": "987e6543-e21b-12d3-a456-426614174000"
          },
          "billingEnabled": {
            "type": "boolean",
            "description": "Whether billing is enabled for this group",
            "example": false
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp when the group was created (UTC)",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "websites": {
            "type": "array",
            "description": "Websites associated with this group",
            "items": {
              "$ref": "#/components/schemas/GroupWebsite"
            }
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "**Partner-only.** The partner-supplied identifier mapped to this group. Only present on responses to callers whose organization is flagged as a partner. Direct-customer responses omit the field entirely. `null` indicates no mapping exists for this group.",
            "example": "acct_9e4c1b8d"
          }
        }
      },
      "GroupWebsite": {
        "type": "object",
        "description": "A website associated with a group",
        "required": ["id", "websiteUrl", "websiteName"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the website",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "websiteUrl": {
            "type": "string",
            "description": "The URL of the website",
            "example": "example.com"
          },
          "websiteName": {
            "type": "string",
            "description": "Display name of the website",
            "example": "My Awesome Blog"
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "**Partner-only.** The partner-supplied identifier mapped to this website. Only present on responses to callers whose organization is flagged as a partner. Direct-customer responses omit the field entirely. `null` indicates no mapping exists for this website.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "CreateGroupRequest": {
        "type": "object",
        "description": "Request body for creating a new group",
        "required": ["name", "website_ids"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "description": "Name of the group.",
            "example": "Enterprise Clients"
          },
          "website_ids": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "List of website IDs to include in the group. All websites must belong to your organization. Duplicate IDs are collapsed to a single membership.",
            "example": [
              "123e4567-e89b-12d3-a456-426614174000",
              "987e6543-e21b-12d3-a456-426614174000"
            ]
          },
          "billing_enabled": {
            "type": "boolean",
            "default": false,
            "description": "Whether to enable billing for this group",
            "example": false
          },
          "external_id": {
            "type": "string",
            "minLength": 1,
            "description": "**Partner-only.** An identifier from your own system to map to this Athena group. Accepted only when authenticating with an API key for an organization flagged as a partner. Sending this field as a direct customer returns `403 Forbidden`. Must be unique per resource type within your organization \u2014 duplicates return `409` with the existing resource in the payload.",
            "example": "acct_9e4c1b8d"
          }
        }
      },
      "CreatedGroup": {
        "type": "object",
        "description": "A newly created group resource",
        "required": [
          "id",
          "name",
          "orgId",
          "billingEnabled",
          "websiteIds",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the group",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "name": {
            "type": "string",
            "description": "Name of the group",
            "example": "Enterprise Clients"
          },
          "orgId": {
            "type": "string",
            "format": "uuid",
            "description": "The organization ID the group belongs to",
            "example": "987e6543-e21b-12d3-a456-426614174000"
          },
          "billingEnabled": {
            "type": "boolean",
            "description": "Whether billing is enabled for this group",
            "example": false
          },
          "websiteIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "List of website IDs associated with this group",
            "example": ["123e4567-e89b-12d3-a456-426614174000"]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp when the group was created (UTC)",
            "example": "2024-06-15T10:30:00.000Z"
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "**Partner-only.** Echoes the `external_id` from the create request if provided, or `null` if the partner did not supply one. Only present on responses to partner API keys \u2014 direct-customer responses omit the field.",
            "example": "acct_9e4c1b8d"
          }
        }
      },
      "UpdateWebsiteRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Request body for updating a website. `external_id` is required; unknown fields are rejected with `400`.",
        "required": ["external_id"],
        "properties": {
          "external_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "nullable": true,
            "description": "**Partner-only.** Partner-supplied identifier to attach to this website. Pass a non-empty string to set or replace the mapping, or `null` to clear an existing mapping. Surrounding whitespace is trimmed; a blank value or one longer than 255 characters returns `400`. Accepted only when authenticating with an API key for an organization flagged as a partner. Sending this field as a direct customer returns `403 Forbidden`. Must be unique per resource type within your organization: setting a value already used by another website returns `409` with the existing website in the payload.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "UpdateGroupRequest": {
        "type": "object",
        "description": "Request body for updating a group. At least one field must be provided.",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "description": "New name for the group.",
            "example": "Renamed Group"
          },
          "add_website_ids": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Website IDs to add to the group. Must belong to your organization. Websites already in the group are silently ignored.",
            "example": ["123e4567-e89b-12d3-a456-426614174000"]
          },
          "remove_website_ids": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Website IDs to remove from the group. IDs not currently in the group are silently ignored.",
            "example": ["987e6543-e21b-12d3-a456-426614174000"]
          },
          "external_id": {
            "type": "string",
            "minLength": 1,
            "nullable": true,
            "description": "**Partner-only.** Partner-supplied identifier to attach to this group. Pass a non-empty string to set or replace the mapping, or `null` to clear an existing mapping. Accepted only when authenticating with an API key for an organization flagged as a partner. Sending this field as a direct customer returns `403 Forbidden`. Must be unique per resource type within your organization \u2014 setting a value already used by another group returns `409` with the existing resource in the payload.",
            "example": "acct_9e4c1b8d"
          },
          "billing_enabled": {
            "type": "boolean",
            "description": "Set to `true` to enable billing for this group. This provisions a billing entity in the upstream billing provider, which is a prerequisite for setting credits on the group (a partner-only operation). Idempotent \u2014 safe to call on groups whose entity was never created or whose initial provisioning failed silently. Set to `false` to disable the flag without destroying existing billing state; credit balances and usage history are preserved. Returns `502` if the upstream billing provider fails to provision the entity \u2014 in that case the database is not modified, so the request can be retried cleanly.",
            "example": true
          }
        }
      },
      "CancelSubscriptionRequest": {
        "type": "object",
        "description": "Request body for canceling a subscription",
        "required": ["website_id", "product_id"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The ID of the website to cancel the subscription for",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "product_id": {
            "type": "string",
            "description": "The ID of the product/subscription to cancel",
            "example": "pro_monthly"
          }
        }
      },
      "UpdateMemberRoleRequest": {
        "type": "object",
        "description": "Request body for updating a member's role",
        "required": ["role"],
        "properties": {
          "role": {
            "type": "string",
            "enum": ["admin", "viewer"],
            "description": "The new role to assign to the member",
            "example": "admin"
          }
        }
      },
      "UpdateOrgMemberRoleRequest": {
        "type": "object",
        "description": "Request body for updating an organization member's role. Provide exactly one of `role` or `role_id`.",
        "properties": {
          "role": {
            "type": "string",
            "enum": ["admin", "viewer"],
            "description": "Coarse role to assign. Mutually exclusive with `role_id`.",
            "example": "admin"
          },
          "role_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
            "description": "Assign any role by ID \u2014 a system role or one of your organization's custom roles (see `GET /api/v1/roles`). Mutually exclusive with `role`. Returns 404 if the role does not exist or belongs to another organization. System role IDs are GUID-shaped sentinels (e.g. `00000000-0000-0000-0000-000000000001`), not RFC 4122 UUIDs.",
            "example": "789e0123-e89b-12d3-a456-426614174000"
          }
        }
      },
      "UpdateGroupMemberRoleRequest": {
        "type": "object",
        "description": "Request body for updating a group member's role. Provide exactly one of `role` or `role_id`.",
        "properties": {
          "role": {
            "type": "string",
            "enum": ["admin", "viewer"],
            "description": "Coarse role to assign. Mutually exclusive with `role_id`.",
            "example": "viewer"
          },
          "role_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
            "description": "Assign any role by ID: a system role or one of your organization's custom roles (see `GET /api/v1/roles`). Mutually exclusive with `role`. Returns 404 if the role does not exist or belongs to another organization. System role IDs are GUID-shaped sentinels (e.g. `00000000-0000-0000-0000-000000000001`), not RFC 4122 UUIDs. At group scope, roles other than Admin and Viewer are honored for access but are displayed as \"Viewer\" in the dashboard's group member list.",
            "example": "789e0123-e89b-12d3-a456-426614174000"
          }
        }
      },
      "PermissionMatrix": {
        "type": "object",
        "description": "Per-category access levels for a role. Every category is at least 'view'; categories omitted on create/update default to 'view'.",
        "properties": {
          "content": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "prompts": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "competitors": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "analytics": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "integrations": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "brand_knowledge": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "team": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "billing": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "api": {
            "type": "string",
            "enum": ["none", "view", "write"]
          },
          "organization": {
            "type": "string",
            "enum": ["none", "view", "write"]
          }
        }
      },
      "Role": {
        "type": "object",
        "description": "A role available in your organization \u2014 a built-in system role or a custom role.",
        "required": [
          "role_id",
          "name",
          "slug",
          "is_system",
          "permissions",
          "created_at"
        ],
        "properties": {
          "role_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
            "description": "Unique identifier of the role. Usable as `role_id` in invites and member role updates. Built-in system roles use GUID-shaped sentinel IDs (e.g. `00000000-0000-0000-0000-000000000001`), not RFC 4122 UUIDs."
          },
          "name": {
            "type": "string",
            "description": "Display name of the role",
            "example": "Content Manager"
          },
          "slug": {
            "type": "string",
            "description": "Normalized name of the role (e.g. 'admin', 'content-manager')",
            "example": "content-manager"
          },
          "is_system": {
            "type": "boolean",
            "description": "Whether this is a built-in system role (Admin, Editor, Viewer, Billing). System roles cannot be edited or deleted."
          },
          "permissions": {
            "$ref": "#/components/schemas/PermissionMatrix"
          },
          "created_at": {
            "type": "string",
            "description": "When the role was created"
          }
        }
      },
      "CreateRoleRequest": {
        "type": "object",
        "description": "Request body for creating a custom role",
        "required": ["name", "permissions"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name of the role. Must be unique in your organization (case-insensitive) and must not collide with a system role name.",
            "example": "Content Manager"
          },
          "permissions": {
            "$ref": "#/components/schemas/PermissionMatrix"
          }
        }
      },
      "UpdateRoleRequest": {
        "type": "object",
        "description": "Request body for updating a custom role's permissions",
        "required": ["permissions"],
        "properties": {
          "permissions": {
            "$ref": "#/components/schemas/PermissionMatrix"
          }
        }
      },
      "WebsiteMember": {
        "type": "object",
        "description": "A user's membership in a specific website",
        "required": ["user_id", "website_id", "role"],
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the user"
          },
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the website"
          },
          "role": {
            "type": "string",
            "enum": ["admin", "viewer"],
            "description": "The member's role on this website"
          }
        }
      },
      "OrgMember": {
        "type": "object",
        "description": "A user's membership in an organization",
        "required": ["user_id", "org_id", "role"],
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the user"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the organization"
          },
          "role": {
            "type": "string",
            "enum": ["admin", "viewer"],
            "description": "The member's role in the organization"
          }
        }
      },
      "UserWebsite": {
        "type": "object",
        "description": "A website that a user has access to, with information about how that access is granted",
        "required": [
          "id",
          "website_name",
          "website_url",
          "access_type",
          "role"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the website"
          },
          "website_name": {
            "type": "string",
            "description": "Display name of the website"
          },
          "website_url": {
            "type": "string",
            "description": "The domain of the website (without protocol)"
          },
          "access_type": {
            "type": "string",
            "enum": ["organization", "website"],
            "description": "How the user has access to this website. `organization` means they are an organization member and have implicit access to every website in the org. `website` means they have an explicit website_members row for this specific website."
          },
          "role": {
            "type": "string",
            "description": "The user's role. For `access_type: \"organization\"`, this is the organization role. For `access_type: \"website\"`, this is the per-website role. Each role is its slug \u2014 the role's normalized name (lowercase, no spaces): `admin`, `viewer`, `editor`, `billing`, or a custom role's id (e.g. `contentmanager`). `admin` and `viewer` are unchanged from prior versions."
          },
          "external_id": {
            "type": "string",
            "nullable": true,
            "description": "**Partner-only.** The partner-supplied identifier mapped to this website. Only present on responses to callers whose organization is flagged as a partner. Direct-customer responses omit the field entirely. `null` indicates no mapping exists for this website. Snake_case to match this endpoint's field naming.",
            "example": "ws_a7f3b2c9"
          }
        }
      },
      "OrgMemberListItem": {
        "type": "object",
        "description": "A member of an organization, with user details",
        "required": ["user_id", "email", "role", "created_at"],
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the user"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "The user's email address"
          },
          "first_name": {
            "type": "string",
            "nullable": true,
            "description": "The user's first name, if set"
          },
          "last_name": {
            "type": "string",
            "nullable": true,
            "description": "The user's last name, if set"
          },
          "role": {
            "type": "string",
            "description": "The user's role in the organization, as its slug: `admin`, `viewer`, `editor`, `billing`, or a custom role's id (e.g. `contentmanager`). `admin` and `viewer` are unchanged from prior versions."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the org membership was created (UTC)"
          }
        }
      },
      "WebsiteMemberListItem": {
        "type": "object",
        "description": "A user with access to a website. Includes both organization members (implicit access to every website in the org) and users with explicit website membership.",
        "required": ["user_id", "email", "role", "access_type", "created_at"],
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the user"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "The user's email address"
          },
          "first_name": {
            "type": "string",
            "nullable": true,
            "description": "The user's first name, if set"
          },
          "last_name": {
            "type": "string",
            "nullable": true,
            "description": "The user's last name, if set"
          },
          "role": {
            "type": "string",
            "description": "The user's role. For `access_type: \"organization\"`, this is the organization role. For `access_type: \"website\"`, this is the per-website role. Each role is its slug \u2014 the role's normalized name (lowercase, no spaces): `admin`, `viewer`, `editor`, `billing`, or a custom role's id (e.g. `contentmanager`). `admin` and `viewer` are unchanged from prior versions."
          },
          "access_type": {
            "type": "string",
            "enum": ["organization", "website"],
            "description": "How the user has access to the website. `organization` = implicit access via org membership. `website` = explicit website_members row."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the membership row was created (UTC)"
          }
        }
      },
      "GroupMemberListItem": {
        "type": "object",
        "description": "A user with access to a group. Includes both organization members (implicit access to every group in the org) and users with explicit group membership.",
        "required": ["user_id", "email", "role", "access_type", "created_at"],
        "properties": {
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier of the user"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "The user's email address"
          },
          "first_name": {
            "type": "string",
            "nullable": true,
            "description": "The user's first name, if set"
          },
          "last_name": {
            "type": "string",
            "nullable": true,
            "description": "The user's last name, if set"
          },
          "role": {
            "type": "string",
            "description": "The user's role. For `access_type: \"organization\"`, this is the organization role. For `access_type: \"group\"`, this is the per-group role. Each role is its slug \u2014 the role's normalized name (lowercase, no spaces): `admin`, `viewer`, `editor`, `billing`, or a custom role's id (e.g. `contentmanager`). `admin` and `viewer` are unchanged from prior versions."
          },
          "access_type": {
            "type": "string",
            "enum": ["organization", "group"],
            "description": "How the user has access to the group. `organization` = implicit access via org membership. `group` = explicit group_members row."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the membership row was created (UTC)"
          }
        }
      },
      "SavedView": {
        "type": "object",
        "description": "A saved view (filter preset) for a website",
        "required": [
          "id",
          "name",
          "icon",
          "website_id",
          "user_id",
          "filters",
          "created_at",
          "updated_at",
          "created_by"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for the saved view",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "name": {
            "type": "string",
            "description": "Display name of the saved view",
            "example": "Branded queries \u2014 last 30 days"
          },
          "icon": {
            "type": "string",
            "nullable": true,
            "description": "Optional icon identifier",
            "example": "star"
          },
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The website this saved view belongs to",
            "example": "987e6543-e21b-12d3-a456-426614174000"
          },
          "user_id": {
            "type": "string",
            "nullable": true,
            "description": "The ID of the user who created the saved view. Null when the view was created via the API (api-key sessions carry no user identity); such views can only be edited or deleted by website admins.",
            "example": "456e7890-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "type": "object",
            "description": "Filter preset payload. Shape mirrors the dashboard filter state.",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp when the saved view was created (UTC)",
            "example": "2026-04-01T10:30:00.000Z"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp when the saved view was last updated (UTC)",
            "example": "2026-04-15T12:00:00.000Z"
          },
          "created_by": {
            "type": "object",
            "nullable": true,
            "description": "User who created the saved view",
            "required": [
              "id",
              "email",
              "first_name",
              "last_name",
              "display_name"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "User ID"
              },
              "email": {
                "type": "string",
                "format": "email",
                "description": "User email"
              },
              "first_name": {
                "type": "string",
                "nullable": true,
                "description": "User first name"
              },
              "last_name": {
                "type": "string",
                "nullable": true,
                "description": "User last name"
              },
              "display_name": {
                "type": "string",
                "description": "Computed display name (full name when available, otherwise email)"
              }
            }
          }
        }
      },
      "GroupSavedView": {
        "type": "object",
        "description": "A group-level saved view (filter preset) shared across the websites in a group",
        "required": [
          "id",
          "name",
          "icon",
          "website_id",
          "group_id",
          "user_id",
          "filters",
          "created_at",
          "created_by"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for the group saved view"
          },
          "name": {
            "type": "string",
            "description": "Display name of the saved view"
          },
          "icon": {
            "type": "string",
            "description": "Icon identifier (defaults to RiBarChartLine)"
          },
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The website this saved view was authored from"
          },
          "group_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The group this saved view belongs to"
          },
          "user_id": {
            "type": "string",
            "nullable": true,
            "description": "The user who created the saved view"
          },
          "filters": {
            "type": "object",
            "description": "Group-scoped filter preset payload (models, prompt type, prompt status, variation, website ids, group prompt ids, locations, personas, prompt tags, target identifiers).",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp when the group saved view was created (UTC)"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp when the group saved view was last updated (UTC). Optional."
          },
          "created_by": {
            "type": "object",
            "nullable": true,
            "description": "User who created the saved view",
            "required": [
              "id",
              "email",
              "first_name",
              "last_name",
              "display_name"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "first_name": {
                "type": "string",
                "nullable": true
              },
              "last_name": {
                "type": "string",
                "nullable": true
              },
              "display_name": {
                "type": "string"
              }
            }
          }
        }
      },
      "ContentSheet": {
        "type": "object",
        "description": "A Content Hub tab. Tabs split tracked content by workstream (1st-party drafts, 3rd-party placements, Reddit, etc.).",
        "required": [
          "id",
          "name",
          "sheet_type",
          "is_default",
          "position",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the sheet.",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "name": {
            "type": "string",
            "description": "Human-readable name shown in the Content Hub UI.",
            "example": "Reddit Mentions"
          },
          "sheet_type": {
            "type": "string",
            "enum": ["view", "sheet"],
            "description": "`sheet`: content is pinned to this tab via `content.sheet_id`. `view`: saved filter / column layout over the main content pool \u2014 content matches dynamically and has no `sheet_id` set.",
            "example": "sheet"
          },
          "is_default": {
            "type": "boolean",
            "description": "Whether this tab is the workspace default. Exactly one tab per website has `is_default: true`.",
            "example": false
          },
          "position": {
            "type": "integer",
            "description": "Sort order in the UI (ascending).",
            "example": 1
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the sheet was created (UTC).",
            "example": "2024-01-01T00:00:00.000Z"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the sheet was last modified (UTC).",
            "example": "2024-02-15T12:34:56.000Z"
          }
        }
      },
      "ContentListRequest": {
        "type": "object",
        "description": "Request body for listing tracked content.",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The website to list tracked content for.",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "allOf": [
              { "$ref": "#/components/schemas/ApiFilters" },
              {
                "type": "object",
                "properties": {
                  "persona_ids": {
                    "type": "array",
                    "description": "Persona IDs to filter to (list them with GET /api/v1/personas). Omit for all personas.",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "prompt_tags": {
                    "type": "array",
                    "description": "Prompt tag IDs to filter prompts by (list them with GET /api/v1/prompt-tags). An entry can also be `type:high_intent` (branded prompts) or `type:discovery` (non-branded prompts) to filter by prompt type. Omit for all tags.",
                    "items": {
                      "oneOf": [
                        { "type": "string", "format": "uuid" },
                        {
                          "type": "string",
                          "enum": ["type:discovery", "type:high_intent"]
                        }
                      ]
                    }
                  },
                  "prompt_tags_operator": {
                    "type": "string",
                    "enum": ["is_any_of", "has_all_of"],
                    "description": "How the tag IDs in prompt_tags combine: is_any_of matches prompts with any listed tag, has_all_of only prompts carrying every listed tag. `type:` entries are not combined with the tags this way: a prompt must also have one of the listed types. Defaults to is_any_of."
                  }
                }
              }
            ]
          },
          "content_type": {
            "type": "string",
            "enum": [
              "external",
              "imported",
              "manual",
              "athena_created",
              "draft",
              "snipe",
              "optimize",
              "slice"
            ],
            "description": "Restrict to a single content type. `manual` is user-authored content created directly in the editor (the Blank Editor flow). `athena_created` is a shortcut for the four Athena-generated subtypes (draft, snipe, optimize, slice). Omit to span every type. This endpoint lists tracked (published) content, so a draft-state row \u2014 `manual`, `draft`, `snipe`, `optimize`, or `slice` \u2014 appears only after it is published."
          },
          "sheet_id": {
            "type": "string",
            "format": "uuid",
            "description": "Restrict to content on a single Content Hub tab. Use `GET /api/v1/content/sheets` to discover IDs. A `sheet` tab lists its own content; a `view` tab, the default tab included, lists the shared main pool (content not filed in any sheet), without the view's saved filters. Omit to span every tab."
          },
          "mentioned": {
            "type": "boolean",
            "description": "If `true`, only count responses that mention your brand. If `false`, only count responses that do not. Omit to count every response."
          },
          "page_num": {
            "type": "integer",
            "minimum": 0,
            "default": 0,
            "description": "Zero-indexed page number."
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 50,
            "description": "Number of items per page (1\u2013100)."
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z"
          },
          "sheet_id": "00000000-0000-4000-8000-000000000001",
          "page_size": 50
        }
      },
      "ContentItem": {
        "type": "object",
        "description": "A tracked content item (1st-party draft, imported page, 3rd-party placement, etc.) with citation and impression metrics joined for the requested date range.",
        "required": [
          "content_id",
          "title",
          "url",
          "normalized_url",
          "type",
          "topic_name",
          "sheet_id",
          "sheet_name",
          "citations",
          "citation_percent",
          "estimated_impressions",
          "total_responses",
          "mark_as_done_time",
          "created_at"
        ],
        "properties": {
          "content_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the content item. Pass this as `content_id` to `POST /api/v1/content/prompts` to drill into per-prompt citation data.",
            "example": "11111111-2222-3333-4444-555555555555"
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "Page or post title (nullable for unscraped URLs).",
            "example": "Best CRMs for Startups, Reviewed"
          },
          "url": {
            "type": "string",
            "nullable": true,
            "description": "Canonical URL (display form, may include `www.`).",
            "example": "example.com/blog/crm-roundup"
          },
          "normalized_url": {
            "type": "string",
            "nullable": true,
            "description": "URL after protocol/trailing-slash normalization. Used to join with citation data.",
            "example": "example.com/blog/crm-roundup"
          },
          "type": {
            "type": "string",
            "nullable": true,
            "description": "Content type \u2014 one of `external`, `imported`, `draft`, `snipe`, `optimize`, `slice` (or null for legacy rows).",
            "example": "external"
          },
          "topic_name": {
            "type": "string",
            "nullable": true,
            "description": "Topic the content is paired with (if any). 3rd-party content often has no topic.",
            "example": "CRM Software"
          },
          "sheet_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Content Hub tab the item is pinned to. `null` for content not pinned to any tab."
          },
          "sheet_name": {
            "type": "string",
            "nullable": true,
            "description": "Human-readable name of the tab. `null` when `sheet_id` is null.",
            "example": "3rd-Party Placements"
          },
          "citations": {
            "type": "number",
            "description": "Count of AI responses in the date range that cite this URL.",
            "example": 42
          },
          "citation_percent": {
            "type": "number",
            "description": "Percentage of all responses (in the date range, matching the filters) that cite this URL.",
            "example": 12.5
          },
          "estimated_impressions": {
            "type": "number",
            "nullable": true,
            "description": "Estimated impressions attributable to the URL across the date range. May be null when impression modeling is not available for the matched prompts.",
            "example": 18400
          },
          "total_responses": {
            "type": "number",
            "description": "Total responses considered for the citation calculation (the denominator behind `citation_percent`).",
            "example": 336
          },
          "mark_as_done_time": {
            "type": "string",
            "format": "date-time",
            "description": "When the content was marked as published / done in Content Hub. Falls back to `created_at` when the row was never marked.",
            "example": "2024-01-15T00:00:00.000Z"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the content row was created (UTC).",
            "example": "2024-01-10T00:00:00.000Z"
          }
        }
      },
      "ActivityActor": {
        "type": "object",
        "description": "Who made the change. A person is identified by id and email in `user`; an API key is identified by id and name so integrations can skip their own writes.",
        "required": ["type", "api_key_id", "api_key_name", "user"],
        "properties": {
          "type": {
            "type": "string",
            "enum": ["user", "api_key", "system"],
            "description": "`user` for a change made in the app, `api_key` for one made through the API, `system` for an automated change or one whose API key has since been deleted."
          },
          "api_key_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Id of the API key that made the change, when `type` is `api_key`."
          },
          "api_key_name": {
            "type": "string",
            "nullable": true,
            "description": "Name of that API key."
          },
          "user": {
            "type": "object",
            "nullable": true,
            "description": "The person who made the change, when `type` is `user`. `null` for API-key and system changes, and for a person outside the websites a scoped key can access.",
            "required": ["id", "email"],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "User id."
              },
              "email": {
                "type": "string",
                "format": "email",
                "description": "User email."
              }
            }
          }
        }
      },
      "ActivityEntry": {
        "type": "object",
        "required": [
          "id",
          "occurred_at",
          "website_id",
          "entity_type",
          "change_type",
          "entity_ids",
          "actor"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Stable, unique id of the change."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the change happened."
          },
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "Website the change belongs to."
          },
          "entity_type": {
            "type": "string",
            "enum": ["prompt", "topic", "prompt_tag"]
          },
          "change_type": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "deleted",
              "restored",
              "paused",
              "unpaused"
            ]
          },
          "entity_ids": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Ids of the affected entities. `null` means the affected set is unknown: re-list the website."
          },
          "actor": {
            "$ref": "#/components/schemas/ActivityActor"
          }
        }
      },
      "ActivityListResponse": {
        "type": "object",
        "required": ["activity", "pagination"],
        "properties": {
          "activity": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActivityEntry"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "Pagination": {
        "type": "object",
        "description": "Pagination metadata. Uses `page_size + 1` lookahead \u2014 `has_more=true` means the next page is non-empty. No total-count field, by design (avoids the extra `COUNT(*)` round-trip).",
        "required": ["page_num", "page_size", "has_more"],
        "properties": {
          "page_num": {
            "type": "integer",
            "description": "Zero-indexed page number returned.",
            "example": 0
          },
          "page_size": {
            "type": "integer",
            "description": "Maximum items per page.",
            "example": 50
          },
          "has_more": {
            "type": "boolean",
            "description": "`true` if another page is available.",
            "example": true
          }
        }
      },
      "ContentListResponse": {
        "type": "object",
        "required": ["content", "pagination"],
        "properties": {
          "content": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentItem"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "ContentInventoryItem": {
        "type": "object",
        "description": "A Content Hub item as listed by `GET /api/v1/content/items`: identity and workflow fields only, no metrics. Published rows, unpublished drafts and tracked pages share this shape.",
        "required": [
          "content_id",
          "title",
          "type",
          "stage",
          "url",
          "normalized_url",
          "sheet_id",
          "sheet_name",
          "topic_name",
          "prompt_ids",
          "prompt_count",
          "mark_as_done_time",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "content_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the content item. Pass it to `GET /api/v1/content/{content_id}` to read the brief and body.",
            "example": "11111111-2222-3333-4444-555555555555"
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "Page or post title (nullable for unscraped URLs).",
            "example": "How to Apply Foundation on Mature Skin"
          },
          "type": {
            "type": "string",
            "nullable": true,
            "description": "How the content entered the hub: `draft` (Athena-written article), `optimize` (rewrite of an existing page), `snipe`, `slice`, `manual` (authored in the editor), `external` (added manually), `imported` (via GA4). `null` for legacy rows.",
            "example": "draft"
          },
          "stage": {
            "type": "string",
            "nullable": true,
            "enum": [
              "scheduled",
              "pending",
              "pending_brief",
              "generated_brief",
              "pending_article",
              "generated",
              "done",
              "failed"
            ],
            "description": "Raw pipeline workflow state, not a publication flag. `null` when the item has no pipeline record (most external and imported tracked pages). `generated` means the text is ready but unpublished (manual editor items carry it too); `done` means published or marked done; `scheduled` means a publish is scheduled. An item counts as published only when its stage is `done` (or it is an external or imported page) and it has a `url`.",
            "example": "generated"
          },
          "url": {
            "type": "string",
            "nullable": true,
            "description": "Canonical URL (display form, may include `www.`). `null` until the item is published somewhere.",
            "example": null
          },
          "normalized_url": {
            "type": "string",
            "nullable": true,
            "description": "URL after protocol/trailing-slash normalization. Used to join with citation data.",
            "example": null
          },
          "sheet_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Content Hub tab the item is pinned to. `null` for content in the shared main pool."
          },
          "sheet_name": {
            "type": "string",
            "nullable": true,
            "description": "Human-readable name of the tab. `null` when `sheet_id` is null.",
            "example": "Drafts - sprint 1"
          },
          "topic_name": {
            "type": "string",
            "nullable": true,
            "description": "Topic the content is paired with (if any).",
            "example": "Makeup for Mature Skin"
          },
          "prompt_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The prompts this item was written for (its targeting), capped at 25 per row; `prompt_count` is the untruncated size. Includes soft-deleted prompts, which `GET /api/v1/prompts` does not list. Empty when no targeting was recorded, which is normal for imported or externally tracked pages. Not the prompts whose answers cited the page; see `POST /api/v1/content/prompts` for that."
          },
          "prompt_count": {
            "type": "integer",
            "description": "Total number of prompts this item targets, including any beyond the 25 in `prompt_ids`. Read the rest through `GET /api/v1/content/{content_id}`.",
            "example": 1
          },
          "mark_as_done_time": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the content was marked as published / done in Content Hub. `null` while unpublished.",
            "example": null
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the content row was created (UTC).",
            "example": "2026-09-01T20:59:53.000Z"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "The newer of the content row's and its pipeline record's last update (UTC), so generation progress bumps it.",
            "example": "2026-09-01T21:09:04.000Z"
          }
        }
      },
      "ContentItemsListResponse": {
        "type": "object",
        "required": ["content", "pagination"],
        "properties": {
          "content": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentInventoryItem"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "ContentPromptBreakdownRequest": {
        "type": "object",
        "description": "Request body for drilling into the prompts that cite a single content item.",
        "required": ["website_id", "content_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The website that owns the content item. Must match the content's website.",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "content_id": {
            "type": "string",
            "format": "uuid",
            "description": "The `content_id` returned by `POST /api/v1/content`. The endpoint resolves this server-side to a normalized URL and queries every prompt whose responses cite it.",
            "example": "11111111-2222-3333-4444-555555555555"
          },
          "filters": {
            "$ref": "#/components/schemas/ApiFilters"
          },
          "mentioned": {
            "type": "boolean",
            "description": "If `true`, only count responses that mention your brand. If `false`, only responses that don't. Omit to count every response."
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "content_id": "11111111-2222-3333-4444-555555555555",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z"
          }
        }
      },
      "ContentPrompt": {
        "type": "object",
        "description": "A prompt whose AI responses cite the requested content.",
        "required": [
          "prompt_id",
          "prompt",
          "citation_percent",
          "citations",
          "estimated_impressions"
        ],
        "properties": {
          "prompt_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the prompt.",
            "example": "22222222-3333-4444-5555-666666666666"
          },
          "prompt": {
            "type": "string",
            "description": "Prompt text.",
            "example": "what are the best CRMs for early-stage startups?"
          },
          "citation_percent": {
            "type": "number",
            "description": "Percentage of this prompt's responses (in the date range) that cite the content URL.",
            "example": 33.3
          },
          "citations": {
            "type": "number",
            "description": "Count of this prompt's responses (in the date range) that cite the content URL.",
            "example": 5
          },
          "estimated_impressions": {
            "type": "number",
            "nullable": true,
            "description": "Estimated impressions attributable to this prompt across the date range. May be null when impression modeling is not available.",
            "example": 1200
          }
        }
      },
      "ContentPromptBreakdownResponse": {
        "type": "object",
        "required": [
          "content_id",
          "content_url",
          "content_normalized_url",
          "prompts"
        ],
        "properties": {
          "content_id": {
            "type": "string",
            "format": "uuid",
            "description": "The `content_id` that was queried."
          },
          "content_url": {
            "type": "string",
            "nullable": true,
            "description": "The content's display URL (may be null for legacy rows)."
          },
          "content_normalized_url": {
            "type": "string",
            "nullable": true,
            "description": "The content's normalized URL \u2014 the value joined against citation data. `null` for legacy rows that were never normalized; in that case `prompts` is always `[]`."
          },
          "prompts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentPrompt"
            }
          }
        }
      },
      "ContentDetailResponse": {
        "type": "object",
        "required": [
          "content_id",
          "title",
          "url",
          "normalized_url",
          "source_url",
          "type",
          "sheet_id",
          "status",
          "brief",
          "body",
          "meta_description",
          "cited_urls",
          "internal_links",
          "brief_cited_urls",
          "brief_internal_links",
          "optimize_summary",
          "linkedin_post",
          "x_post",
          "facebook_post",
          "instagram_post",
          "reddit_post",
          "topic_name",
          "prompts",
          "prompts_total",
          "mark_as_done_time",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "content_id": {
            "type": "string",
            "format": "uuid",
            "description": "The content item's id."
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "The content's title."
          },
          "url": {
            "type": "string",
            "nullable": true,
            "description": "The content's display URL."
          },
          "normalized_url": {
            "type": "string",
            "nullable": true,
            "description": "The normalized URL \u2014 the value joined against citation data."
          },
          "source_url": {
            "type": "string",
            "nullable": true,
            "description": "For an `optimize` item, the live page it is based on, available as soon as the item exists and in the same form as `url`. `null` for other content types and for optimizations based on pasted text or a file. Running the optimization again on another page or a file updates it. Unlike `url`, it does not depend on publishing and does not start citation attribution."
          },
          "type": {
            "type": "string",
            "nullable": true,
            "description": "How the content entered the hub: `draft` (Athena-written article), `optimize` (rewrite of an existing page), `snipe`, `slice`, `manual` (authored in the editor), `external` (added manually), `imported` (via GA4).",
            "example": "draft"
          },
          "sheet_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The Content Hub sheet the item belongs to. See `GET /api/v1/content/sheets`."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "done",
              "generated",
              "failed",
              "pending",
              "generated_brief",
              "pending_brief",
              "pending_article",
              "scheduled"
            ],
            "description": "Generation lifecycle status. `pending`/`pending_brief`/`pending_article` mean work is in flight; `generated_brief` means the brief is ready while the article is still being written; `generated` means the text is ready; `done` means published/marked done; `scheduled` means a publish is scheduled. `null` when the item has no generation record yet (e.g. a tracked page that has not been scraped)."
          },
          "brief": {
            "type": "string",
            "nullable": true,
            "description": "The content brief, as markdown. Available once `status` reaches `generated_brief`."
          },
          "body": {
            "type": "string",
            "nullable": true,
            "description": "The article/page body, as markdown. Holds the generated draft, the optimize rewrite, the snipe article, authored text, or the scraped body of a tracked page \u2014 depending on `type`."
          },
          "meta_description": {
            "type": "string",
            "nullable": true,
            "description": "The generated meta description."
          },
          "cited_urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "External source URLs cited by the body. Not to be confused with `citations` on `POST /api/v1/content`, which is the count of AI responses citing this URL."
          },
          "internal_links": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Internal URLs linked from the body."
          },
          "brief_cited_urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "External source URLs referenced by the brief."
          },
          "brief_internal_links": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Internal URLs suggested by the brief."
          },
          "optimize_summary": {
            "type": "object",
            "nullable": true,
            "description": "For `optimize` items: a summary of what the rewrite changed. `null` for other types or when no rewrite has completed.",
            "required": ["overview", "changes"],
            "properties": {
              "overview": {
                "type": "string",
                "description": "One-paragraph overview of the rewrite."
              },
              "changes": {
                "type": "array",
                "description": "Individual changes made by the rewrite.",
                "items": {
                  "type": "object",
                  "required": ["description"],
                  "properties": {
                    "description": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "linkedin_post": {
            "type": "string",
            "nullable": true,
            "description": "Latest completed LinkedIn post generated for this content; falls back to legacy stored values for older content."
          },
          "x_post": {
            "type": "string",
            "nullable": true,
            "description": "Latest completed X post generated for this content; falls back to legacy stored values for older content."
          },
          "facebook_post": {
            "type": "string",
            "nullable": true,
            "description": "Latest completed Facebook post generated for this content; falls back to legacy stored values for older content."
          },
          "instagram_post": {
            "type": "string",
            "nullable": true,
            "description": "Latest completed Instagram post generated for this content; falls back to legacy stored values for older content."
          },
          "reddit_post": {
            "type": "string",
            "nullable": true,
            "description": "Latest completed Reddit post generated for this content; falls back to legacy stored values for older content."
          },
          "topic_name": {
            "type": "string",
            "nullable": true,
            "description": "Name of the topic the content targets, when assigned."
          },
          "prompts": {
            "type": "array",
            "description": "The prompts this content was written to target, oldest association first, capped at 100 entries. When `prompts_total` exceeds 100 the remainder is not currently retrievable. Empty when the item has no prompt targeting, which is normal for imported or externally tracked pages. This is not the same as the prompts that cited the page \u2014 see POST /api/v1/content/prompts for that.",
            "items": {
              "type": "object",
              "required": ["id", "prompt", "topic_name", "status"],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "description": "The prompt's id. Resolvable via GET /api/v1/prompts unless the prompt is deleted, which that endpoint does not list."
                },
                "prompt": {
                  "type": "string",
                  "description": "The prompt text."
                },
                "topic_name": {
                  "type": "string",
                  "nullable": true,
                  "description": "Name of the topic the prompt belongs to, when assigned."
                },
                "status": {
                  "type": "string",
                  "enum": ["active", "paused", "deleted"],
                  "description": "The prompt's current state. Deleted prompts are still listed because the page was written for them and the Content Hub still displays them, but they are no longer tracked and GET /api/v1/prompts omits them."
                }
              }
            }
          },
          "prompts_total": {
            "type": "integer",
            "description": "Total number of prompts targeted by this content, before the 100-entry cap applied to prompts."
          },
          "mark_as_done_time": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the item was marked done/published."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the content item was created."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the content item or its generated text last changed (the newer of the row and generation timestamps)."
          }
        }
      },
      "AIAccessBotDetails": {
        "type": "object",
        "description": "Per-model conversational/training accessibility booleans.",
        "properties": {
          "conversational": {
            "type": "boolean",
            "description": "Live HTTP signal that the model's conversational user-agent is allowed."
          },
          "training": {
            "type": "boolean",
            "description": "Live HTTP signal that the model's training crawler is allowed."
          }
        },
        "required": ["conversational", "training"]
      },
      "AIAccessUIBotAccess": {
        "type": "object",
        "description": "Per-model accessibility map. Keys map to the major answer engines.",
        "properties": {
          "chatgpt": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          },
          "claude": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          },
          "perplexity": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          },
          "gemini": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          },
          "copilot": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          },
          "grok": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          },
          "deepseek": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          },
          "rufus": {
            "$ref": "#/components/schemas/AIAccessBotDetails"
          }
        }
      },
      "AIAccessRawEvidence": {
        "type": "object",
        "properties": {
          "chatgpt": {
            "type": "object",
            "properties": {
              "ChatGPTUser": {
                "type": "boolean",
                "nullable": true
              },
              "OAISearchBot": {
                "type": "boolean",
                "nullable": true
              },
              "GPTBot": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["ChatGPTUser", "OAISearchBot", "GPTBot"]
          },
          "claude": {
            "type": "object",
            "properties": {
              "ClaudeUser": {
                "type": "boolean",
                "nullable": true
              },
              "ClaudeSearchBot": {
                "type": "boolean",
                "nullable": true
              },
              "ClaudeBot": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["ClaudeUser", "ClaudeSearchBot", "ClaudeBot"]
          },
          "gemini": {
            "type": "object",
            "properties": {
              "Googlebot": {
                "type": "boolean",
                "nullable": true
              },
              "GoogleExtended": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["Googlebot", "GoogleExtended"]
          },
          "perplexity": {
            "type": "object",
            "properties": {
              "PerplexityUser": {
                "type": "boolean",
                "nullable": true
              },
              "PerplexityBot": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["PerplexityUser", "PerplexityBot"]
          },
          "copilot": {
            "type": "object",
            "properties": {
              "Bingbot": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["Bingbot"]
          },
          "grok": {
            "type": "object",
            "properties": {
              "XAIBot": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["XAIBot"]
          },
          "deepseek": {
            "type": "object",
            "properties": {
              "DeepSeekBot": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["DeepSeekBot"]
          },
          "rufus": {
            "type": "object",
            "properties": {
              "Amazonbot": {
                "type": "boolean",
                "nullable": true
              }
            },
            "required": ["Amazonbot"]
          }
        },
        "required": [
          "chatgpt",
          "claude",
          "gemini",
          "perplexity",
          "copilot",
          "grok",
          "deepseek",
          "rufus"
        ]
      },
      "AIAccessResult": {
        "type": "object",
        "description": "AI Access observations plus legacy compatibility fields. Use evidence and per-agent diagnostics for authoritative nullable results.",
        "properties": {
          "domain": {
            "type": "string",
            "description": "The domain that was probed."
          },
          "status": {
            "type": "string",
            "enum": ["accessible", "partial", "blocked"],
            "description": "Legacy rollup retained for compatibility. Use evidence.status to distinguish inconclusive checks."
          },
          "http": {
            "$ref": "#/components/schemas/AIAccessUIBotAccess",
            "description": "Legacy per-model booleans retained for compatibility. When Google-Extended has no HTTP observation, Gemini training uses the measured Googlebot response as a compatibility proxy, not proof of training access or permission. Use evidence.http for per-agent nullable observations and evidence.robots for independent policy."
          },
          "robots": {
            "$ref": "#/components/schemas/AIAccessUIBotAccess",
            "description": "Legacy per-model booleans retained for compatibility. Use evidence.robots for per-agent nullable observations and separate search/training."
          },
          "hasSitemap": {
            "type": "boolean",
            "description": "Optional independently verified sitemap result. The current AI Access probe does not check sitemaps and omits this field."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          },
          "error": {
            "type": "string",
            "description": "Populated only when both probes failed."
          },
          "evidence": {
            "type": "object",
            "description": "Authoritative observations. Requests originate from Athena, not verified crawler IP ranges. Null means unknown. ChatGPTUser is retrieval, OAISearchBot is search, GPTBot is training. GoogleExtended is a policy token with no HTTP crawler. Policies and HTTP observations are independent. No guarantee of indexing or citations.",
            "properties": {
              "version": {
                "type": "integer",
                "enum": [2]
              },
              "network": {
                "type": "string",
                "enum": ["athena"]
              },
              "status": {
                "type": "string",
                "enum": ["accessible", "partial", "blocked", "inconclusive"]
              },
              "http": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AIAccessRawEvidence"
                  }
                ],
                "nullable": true
              },
              "robots": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AIAccessRawEvidence"
                  }
                ],
                "nullable": true
              }
            },
            "required": ["version", "network", "status", "http", "robots"]
          }
        },
        "required": ["domain", "status", "checkedAt"]
      },
      "AIAccessBotCheckDetail": {
        "type": "object",
        "description": "Per-agent diagnostic detail. Used to populate the diagnostic log a partner can paste into a host or CDN ticket.",
        "properties": {
          "category": {
            "type": "string",
            "description": "Model category (chatgpt, claude, gemini, ...)."
          },
          "agentKey": {
            "type": "string",
            "description": "Internal key of the user-agent variant."
          },
          "agentName": {
            "type": "string",
            "description": "Human-readable user-agent name (e.g. `GPTBot`, `Googlebot`)."
          },
          "userAgent": {
            "type": "string",
            "description": "Full user-agent string sent during the probe."
          },
          "accessible": {
            "type": "boolean",
            "description": "Whether this user-agent received a successful HTTP response."
          },
          "status": {
            "type": ["integer", "null"],
            "description": "HTTP status code, or null on network/transport error."
          },
          "finalUrl": {
            "type": ["string", "null"],
            "description": "Final URL after any redirects, or null on failure."
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "CDN-relevant response headers (cf-ray, x-vercel-id, x-amz-cf-id, server, etc.)."
          },
          "errorCode": {
            "type": ["string", "null"],
            "description": "Error code when the request failed (e.g. `ENOTFOUND`, `ETIMEDOUT`)."
          },
          "errorMessage": {
            "type": ["string", "null"]
          },
          "durationMs": {
            "type": "integer"
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          },
          "verdict": {
            "type": "string",
            "enum": ["allowed", "challenged", "blocked", "error", "not_tested"],
            "description": "Observed probe outcome. Challenged or error means unknown access. Policy-only tokens are not_tested."
          }
        },
        "required": [
          "category",
          "agentKey",
          "agentName",
          "userAgent",
          "accessible",
          "status",
          "finalUrl",
          "headers",
          "errorCode",
          "errorMessage",
          "durationMs",
          "checkedAt"
        ]
      },
      "AIAccessRobotsCheckDetail": {
        "type": "object",
        "description": "robots.txt fetch diagnostics.",
        "properties": {
          "url": {
            "type": "string"
          },
          "status": {
            "type": ["integer", "null"]
          },
          "finalUrl": {
            "type": ["string", "null"]
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "errorCode": {
            "type": ["string", "null"]
          },
          "errorMessage": {
            "type": ["string", "null"]
          },
          "durationMs": {
            "type": "integer"
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          },
          "source": {
            "type": "string",
            "enum": ["direct", "fallback", "missing"]
          }
        },
        "required": [
          "url",
          "status",
          "finalUrl",
          "headers",
          "errorCode",
          "errorMessage",
          "durationMs",
          "checkedAt",
          "source"
        ]
      },
      "AIAccessDiagnostics": {
        "type": "object",
        "description": "Per-request diagnostic fingerprint. Useful for filing host or CDN tickets.",
        "properties": {
          "userAgentChecks": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/AIAccessBotCheckDetail"
            },
            "description": "Keyed by `${category}.${agentKey}`, e.g. `chatgpt.GPTBot`."
          },
          "robotsCheck": {
            "$ref": "#/components/schemas/AIAccessRobotsCheckDetail"
          }
        },
        "required": ["userAgentChecks"]
      },
      "AIAccessCheckResponse": {
        "type": "object",
        "description": "Successful AI access check response.",
        "properties": {
          "result": {
            "$ref": "#/components/schemas/AIAccessResult"
          },
          "diagnostics": {
            "$ref": "#/components/schemas/AIAccessDiagnostics"
          },
          "log": {
            "type": "string",
            "description": "Plain-text diagnostic log shaped for a host/CDN ticket. Identical to the string the AthenaHQ web app's `Copy log` button produces."
          }
        },
        "required": ["result", "diagnostics", "log"]
      },
      "PitchSummary": {
        "type": "object",
        "description": "A pitch workspace report \u2014 org-scoped, returned in lists without the heavy report payload.",
        "required": [
          "id",
          "company_name",
          "company_url",
          "company_description",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the pitch.",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "company_name": {
            "type": "string",
            "description": "Display name of the company the pitch was created for.",
            "example": "Acme Inc"
          },
          "company_url": {
            "type": "string",
            "description": "The company website domain (without protocol).",
            "example": "acme.com"
          },
          "company_description": {
            "type": "string",
            "description": "Short description of the company captured at pitch creation time.",
            "example": "Acme Inc sells durable industrial widgets to manufacturers."
          },
          "status": {
            "type": "string",
            "enum": ["draft", "processing", "completed", "failed"],
            "description": "Current state of the pitch run. `processing` means the workflow is still generating prompts and responses; `completed` means the report is ready; `failed` means the run errored.",
            "example": "completed"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp (UTC) for when the pitch was created.",
            "example": "2026-05-22T15:04:05.000Z"
          },
          "country": {
            "type": "string",
            "nullable": true,
            "description": "Target country for the pitch, or `null` if no country was set.",
            "example": "United States"
          },
          "language": {
            "type": "string",
            "nullable": true,
            "description": "Target language for the pitch, or `null` if no language was set.",
            "example": "en"
          },
          "type": {
            "type": "string",
            "enum": ["pitch_workspace", "landing_page"],
            "nullable": true,
            "description": "Pitch variant. `pitch_workspace` is the standard pitch report; `landing_page` is generated from a landing page URL. `null` for legacy pitches predating the field.",
            "example": "pitch_workspace"
          }
        }
      },
      "PitchCompetitor": {
        "type": "object",
        "description": "A competitor tracked on a pitch, with aggregate mention and sentiment stats across the pitch's responses.",
        "required": ["id", "name", "url", "mentions", "sentiment"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the pitch competitor row.",
            "example": "11111111-2222-3333-4444-555555555555"
          },
          "name": {
            "type": "string",
            "description": "Competitor display name.",
            "example": "Competitor Co"
          },
          "url": {
            "type": "string",
            "description": "Competitor website (without protocol).",
            "example": "competitor.com"
          },
          "mentions": {
            "type": "integer",
            "description": "Number of pitch responses where this competitor was mentioned.",
            "example": 42
          },
          "sentiment": {
            "type": "integer",
            "description": "Average sentiment across mentions, expressed as an integer percent from 0 to 100. `positive` mentions count as 1, `neutral` as 0.5, and `negative` as 0; the average is then scaled to a percent. `0` when the competitor has no mentions.",
            "minimum": 0,
            "maximum": 100,
            "example": 67
          }
        }
      },
      "PitchPrompt": {
        "type": "object",
        "description": "A prompt generated for a pitch and used to query AI models.",
        "required": ["id", "prompt", "type"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the pitch prompt.",
            "example": "22222222-3333-4444-5555-666666666666"
          },
          "prompt": {
            "type": "string",
            "description": "The prompt text used for generation.",
            "example": "What are the best industrial widget manufacturers?"
          },
          "type": {
            "type": "string",
            "description": "Prompt category. Common values include `discovery` and `high_intent`; other values may be present depending on the pitch generator version.",
            "example": "discovery"
          }
        }
      },
      "PitchAttribute": {
        "type": "object",
        "description": "An attribute (positive or negative trait) extracted from pitch responses, applied to either the target company or its competitors.",
        "required": [
          "id",
          "attribute_name",
          "attribute_type",
          "applies_to",
          "count"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the pitch attribute.",
            "example": "33333333-4444-5555-6666-777777777777"
          },
          "attribute_name": {
            "type": "string",
            "description": "The attribute label.",
            "example": "Reliable delivery"
          },
          "attribute_type": {
            "type": "string",
            "enum": ["positive", "negative"],
            "description": "Whether the attribute is a positive trait or a negative trait.",
            "example": "positive"
          },
          "applies_to": {
            "type": "string",
            "enum": ["target", "competitors"],
            "description": "Whether the attribute describes the target company (`target`) or one of the tracked competitors (`competitors`).",
            "example": "target"
          },
          "count": {
            "type": "integer",
            "description": "How many pitch responses mentioned this attribute.",
            "example": 12
          }
        }
      },
      "PitchSource": {
        "type": "object",
        "description": "A top citing source (root domain) referenced across the pitch's AI responses.",
        "required": ["domain", "mentions"],
        "properties": {
          "domain": {
            "type": "string",
            "description": "Root domain of the citing source. Google Places citations are surfaced as `google.com (Google Places)` to distinguish them from regular `google.com` citations.",
            "example": "wikipedia.org"
          },
          "mentions": {
            "type": "integer",
            "description": "Number of pitch source rows attributed to this domain.",
            "example": 18
          }
        }
      },
      "PitchMetrics": {
        "type": "object",
        "description": "Aggregate metrics computed across the pitch's AI responses.",
        "required": [
          "total_responses",
          "brand_mentions",
          "sentiment_score",
          "response_rate"
        ],
        "properties": {
          "total_responses": {
            "type": "integer",
            "description": "Total number of AI responses collected for this pitch.",
            "example": 120
          },
          "brand_mentions": {
            "type": "integer",
            "description": "Number of responses in which the target company was mentioned.",
            "example": 64
          },
          "sentiment_score": {
            "type": "integer",
            "description": "Average sentiment across mentioning responses, expressed as an integer percent from 0 to 100. `positive` counts as 1, `neutral` as 0.5, and `negative` as 0; the average is then scaled to a percent. `0` when there are no brand mentions.",
            "minimum": 0,
            "maximum": 100,
            "example": 72
          },
          "response_rate": {
            "type": "integer",
            "description": "Share of responses that mentioned the target company, expressed as an integer percent from 0 to 100 (`brand_mentions / total_responses`).",
            "minimum": 0,
            "maximum": 100,
            "example": 53
          }
        }
      },
      "PitchReport": {
        "type": "object",
        "description": "Full pitch report payload returned by `GET /api/v1/pitches/{pitch_id}`.",
        "required": [
          "pitch",
          "competitors",
          "prompts",
          "attributes",
          "sources",
          "metrics"
        ],
        "properties": {
          "pitch": {
            "$ref": "#/components/schemas/PitchSummary"
          },
          "competitors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PitchCompetitor"
            },
            "description": "Competitors tracked on the pitch, with mention counts and sentiment."
          },
          "prompts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PitchPrompt"
            },
            "description": "Prompts generated for the pitch."
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PitchAttribute"
            },
            "description": "Positive and negative attributes extracted from the pitch's responses, for both the target company and its competitors."
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PitchSource"
            },
            "description": "Top 10 citing domains across the pitch's responses, ordered by mention count."
          },
          "metrics": {
            "$ref": "#/components/schemas/PitchMetrics"
          }
        }
      },
      "SourceTypeClassification": {
        "type": "string",
        "enum": ["owned", "competitor", "partner", "third_party"],
        "description": "How the source row is classified relative to the website. `owned` covers the website's own host, every host listed as an owned domain, and their subdomains; a listed owned URL pattern with a path (for example `reddit.com/user/brand`) makes only the pages under that path `owned`, not the whole host. `competitor` matches tracked competitor root domains. `partner` matches configured affiliate domains. `third_party` is the residual bucket (Wikipedia, news, etc.). Per-website source-type overrides apply in this order: an override on the exact URL decides; a host or path the website lists as owned stays `owned`; a domain-level override then decides, including for hosts that are `owned` only as subdomains of a listed domain."
      },
      "SourcesMentionedFilter": {
        "type": "string",
        "enum": ["yes", "no"],
        "description": "If `yes`, only count sources where your brand was mentioned in the citing response. If `no`, only count sources where your brand was NOT mentioned. Omit the field to count every cited source."
      },
      "SourcesSourceTags": {
        "type": "array",
        "description": "Source tags to filter by, matching the Source Tag filter in the app. Each value is a tag ID from the `source_tags__list` MCP tool (built-in tags such as Media or PR Wire, and the website's custom tags), `owned`, `competitor`, `other` (sources the Tags column badges Other: classified outside every built-in category) or `untagged` (sources with no tag). Omit for all sources.",
        "items": {
          "anyOf": [
            { "type": "string", "format": "uuid" },
            {
              "type": "string",
              "enum": ["owned", "competitor", "other", "untagged"]
            }
          ]
        }
      },
      "SourcesSourceTagsOperator": {
        "type": "string",
        "enum": ["is_any_of", "is_not_any_of", "has_all_of"],
        "default": "is_any_of",
        "description": "How `source_tags` combine: `is_any_of` keeps sources carrying any listed tag, `is_not_any_of` drops them, `has_all_of` keeps only sources carrying every listed tag."
      },
      "SourcesPagination": {
        "type": "object",
        "description": "Pagination metadata. Unlike `Pagination` (which uses `has_more` lookahead), the sources surfaces expose a precise `total` count \u2014 the underlying ClickHouse query computes it as a window function in the same scan, so there's no extra round-trip cost.",
        "required": ["page_num", "page_size", "total"],
        "properties": {
          "page_num": {
            "type": "integer",
            "description": "Zero-indexed page number returned.",
            "example": 0
          },
          "page_size": {
            "type": "integer",
            "description": "Maximum items per page.",
            "example": 30
          },
          "total": {
            "type": "integer",
            "description": "Total number of rows matching the filters (across all pages).",
            "example": 142
          }
        }
      },
      "SourcesListRequest": {
        "type": "object",
        "description": "Request body for listing domain-grouped sources.",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The website to list sources for.",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "$ref": "#/components/schemas/ApiFilters"
          },
          "page_num": {
            "type": "integer",
            "minimum": 0,
            "default": 0,
            "description": "Zero-indexed page number."
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 30,
            "description": "Number of rows per page (1\u2013100)."
          },
          "sort_field": {
            "type": "string",
            "enum": [
              "citation_percentage",
              "mention_percentage",
              "competitor_mention_percentage",
              "brand_mention_percentage",
              "estimated_impressions",
              "total_mentions",
              "domain_count",
              "mentions_count",
              "root_domain",
              "response_count",
              "first_seen"
            ],
            "default": "citation_percentage",
            "description": "Column to sort by."
          },
          "sort_direction": {
            "type": "string",
            "enum": ["asc", "desc"],
            "default": "desc"
          },
          "search": {
            "type": "string",
            "nullable": true,
            "description": "Substring filter on `normalized_root_domain`. Protocol (`https://`), `www.`, path, query, and fragment are stripped before matching, so a full URL like `https://www.example.com/foo` collapses to `example.com`."
          },
          "mentioned": {
            "$ref": "#/components/schemas/SourcesMentionedFilter"
          },
          "competitors_mentioned": {
            "$ref": "#/components/schemas/SourcesMentionedFilter"
          },
          "source_tags": {
            "$ref": "#/components/schemas/SourcesSourceTags"
          },
          "source_tags_operator": {
            "$ref": "#/components/schemas/SourcesSourceTagsOperator"
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z"
          },
          "page_size": 30,
          "sort_field": "citation_percentage",
          "sort_direction": "desc"
        }
      },
      "SourceItem": {
        "type": "object",
        "description": "A domain-grouped source row. Identifies one cited root domain with its citation, mention, and impression metrics for the requested date range.",
        "required": [
          "root_domain",
          "total_mentions",
          "response_count",
          "estimated_impressions",
          "domain_count",
          "mention_percentage",
          "citation_percentage",
          "competitor_mention_percentage",
          "brand_mention_percentage",
          "mentions_count",
          "responses_mentioned_count",
          "competitor_ids",
          "default_source_type",
          "source_type_ids",
          "first_seen"
        ],
        "properties": {
          "root_domain": {
            "type": "string",
            "description": "The cited root domain (display form).",
            "example": "wikipedia.org"
          },
          "total_mentions": {
            "type": "number",
            "description": "Total citations of this domain (one per citing response) in the date range.",
            "example": 124
          },
          "response_count": {
            "type": "number",
            "description": "Distinct AI responses citing this domain.",
            "example": 86
          },
          "estimated_impressions": {
            "type": "number",
            "description": "Estimated impressions attributable to this domain across the date range.",
            "example": 18400
          },
          "domain_count": {
            "type": "number",
            "description": "Distinct subdomain count rolled up under this root domain.",
            "example": 31
          },
          "mention_percentage": {
            "type": "number",
            "description": "Citations of this domain as a percentage of all matching responses.",
            "example": 12.3
          },
          "citation_percentage": {
            "type": "number",
            "description": "Same numerator as `mention_percentage`. Kept for backward compatibility with the existing dashboard wire shape.",
            "example": 14.1
          },
          "competitor_mention_percentage": {
            "type": "number",
            "description": "Of the responses citing this domain, the percentage that also mention a tracked competitor.",
            "example": 3.2
          },
          "brand_mention_percentage": {
            "type": "number",
            "description": "Of the responses citing this domain, the percentage that mention the website's brand.",
            "example": 8.9
          },
          "mentions_count": {
            "type": "number",
            "description": "Per-URL rollup: count of cited URLs on this domain where the brand was mentioned.",
            "example": 47
          },
          "responses_mentioned_count": {
            "type": "number",
            "description": "Count of citing responses where the brand was mentioned.",
            "example": 39
          },
          "competitor_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tracked competitors mentioned in responses that cite this domain.",
            "example": []
          },
          "default_source_type": {
            "$ref": "#/components/schemas/SourceTypeClassification"
          },
          "source_type_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Custom source-type tag UUIDs attached to this domain (in addition to `default_source_type`).",
            "example": []
          },
          "first_seen": {
            "type": "string",
            "description": "Earliest citation date for this domain in the date range.",
            "example": "2024-01-04"
          }
        }
      },
      "SourcesListResponse": {
        "type": "object",
        "required": ["sources", "pagination"],
        "properties": {
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SourceItem"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/SourcesPagination"
          }
        }
      },
      "SourcePagesListRequest": {
        "type": "object",
        "description": "Request body for listing per-URL cited pages.",
        "required": ["website_id", "filters"],
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid",
            "description": "The website to list cited URLs for.",
            "example": "123e4567-e89b-12d3-a456-426614174000"
          },
          "filters": {
            "allOf": [
              { "$ref": "#/components/schemas/ApiFilters" },
              {
                "type": "object",
                "properties": {
                  "persona_ids": {
                    "type": "array",
                    "description": "Persona IDs to filter to (list them with GET /api/v1/personas). Omit for all personas.",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "prompt_tags": {
                    "type": "array",
                    "description": "Prompt tag IDs to filter prompts by (list them with GET /api/v1/prompt-tags). An entry can also be `type:high_intent` (branded prompts) or `type:discovery` (non-branded prompts) to filter by prompt type. Omit for all tags.",
                    "items": {
                      "oneOf": [
                        { "type": "string", "format": "uuid" },
                        {
                          "type": "string",
                          "enum": ["type:discovery", "type:high_intent"]
                        }
                      ]
                    }
                  },
                  "prompt_tags_operator": {
                    "type": "string",
                    "enum": ["is_any_of", "has_all_of"],
                    "description": "How the tag IDs in prompt_tags combine: is_any_of matches prompts with any listed tag, has_all_of only prompts carrying every listed tag. `type:` entries are not combined with the tags this way: a prompt must also have one of the listed types, and has_all_of accepts at most one `type:` entry, since a prompt has exactly one type. Defaults to is_any_of."
                  }
                }
              }
            ]
          },
          "page_num": {
            "type": "integer",
            "minimum": 0,
            "default": 0
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 30
          },
          "sort_field": {
            "type": "string",
            "enum": [
              "citation_percentage",
              "estimated_impressions",
              "total_mentions",
              "mentions_count",
              "normalized_url",
              "competitor_ids",
              "first_seen"
            ],
            "default": "citation_percentage"
          },
          "sort_direction": {
            "type": "string",
            "enum": ["asc", "desc"],
            "default": "desc"
          },
          "search": {
            "type": "string",
            "nullable": true,
            "description": "Substring filter on `normalized_url` AND `normalized_root_domain`. Protocol (`https://`), `www.`, query, and fragment are stripped before matching; path is preserved so URL-specific searches still work."
          },
          "mentioned": {
            "$ref": "#/components/schemas/SourcesMentionedFilter"
          },
          "competitors_mentioned": {
            "$ref": "#/components/schemas/SourcesMentionedFilter"
          },
          "source_tags": {
            "$ref": "#/components/schemas/SourcesSourceTags"
          },
          "source_tags_operator": {
            "$ref": "#/components/schemas/SourcesSourceTagsOperator"
          }
        },
        "example": {
          "website_id": "123e4567-e89b-12d3-a456-426614174000",
          "filters": {
            "start_date": "2024-01-01T00:00:00.000Z",
            "end_date": "2024-01-31T23:59:59.999Z"
          },
          "page_size": 30
        }
      },
      "SourcePageDailyMention": {
        "type": "object",
        "description": "A single day of the per-URL citation sparkline.",
        "required": ["date", "citation_percentage"],
        "properties": {
          "date": {
            "type": "string",
            "description": "Date (YYYY-MM-DD) the citation percentage was measured on.",
            "example": "2024-01-07"
          },
          "citation_percentage": {
            "type": "number",
            "description": "Percentage of all responses on this date that cite the URL.",
            "example": 0.4
          }
        }
      },
      "SourcePageItem": {
        "type": "object",
        "description": "A per-URL cited page row with metrics + sparkline.",
        "required": [
          "normalized_url",
          "domain",
          "root_domain",
          "normalized_root_domain",
          "total_mentions",
          "estimated_impressions",
          "citation_percentage",
          "mentions_count",
          "competitor_ids",
          "default_source_type",
          "source_type_ids",
          "first_seen",
          "daily_mentions"
        ],
        "properties": {
          "normalized_url": {
            "type": "string",
            "description": "The cited URL after protocol/www/trailing-slash normalization. Domain is lower-cased; path case is preserved.",
            "example": "wikipedia.org/wiki/Customer_Relationship_Management"
          },
          "domain": {
            "type": "string",
            "description": "Display-form domain (may include `www.`, subdomains).",
            "example": "en.wikipedia.org"
          },
          "root_domain": {
            "type": "string",
            "description": "Display-form root domain.",
            "example": "wikipedia.org"
          },
          "normalized_root_domain": {
            "type": "string",
            "description": "Lower-cased root domain \u2014 useful for joining against `POST /api/v1/sources` rows.",
            "example": "wikipedia.org"
          },
          "total_mentions": {
            "type": "number",
            "description": "Total citations of this URL (one per citing response) in the date range.",
            "example": 24
          },
          "estimated_impressions": {
            "type": "number",
            "description": "Estimated impressions attributable to this URL across the date range.",
            "example": 3400
          },
          "citation_percentage": {
            "type": "number",
            "description": "Citations of this URL as a percentage of all matching responses.",
            "example": 2.7
          },
          "mentions_count": {
            "type": "number",
            "description": "Count of citing responses on this URL where the brand was mentioned.",
            "example": 9
          },
          "competitor_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Tracked competitors mentioned in responses that cite this URL.",
            "example": []
          },
          "default_source_type": {
            "$ref": "#/components/schemas/SourceTypeClassification"
          },
          "source_type_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Custom source-type tag UUIDs attached to this URL or its root domain."
          },
          "first_seen": {
            "type": "string",
            "description": "Earliest citation date for this URL in the date range.",
            "example": "2024-01-07"
          },
          "daily_mentions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SourcePageDailyMention"
            },
            "description": "Per-day citation percentage sparkline for this URL across the date range. Empty array when no citations occurred."
          }
        }
      },
      "SourcePagesListResponse": {
        "type": "object",
        "required": ["pages", "pagination"],
        "properties": {
          "pages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SourcePageItem"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/SourcesPagination"
          }
        }
      },
      "PromptTag": {
        "type": "object",
        "description": "A prompt tag reference",
        "required": ["id", "name"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the tag",
            "example": "223e4567-e89b-12d3-a456-426614174111"
          },
          "name": {
            "type": "string",
            "description": "Tag name",
            "example": "Caption Phones"
          }
        }
      },
      "PersonaWithCount": {
        "type": "object",
        "description": "A persona with its assigned-prompt count",
        "required": ["id", "name", "description", "prompt_count"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the persona",
            "example": "323e4567-e89b-12d3-a456-426614174222"
          },
          "name": {
            "type": "string",
            "description": "Persona name",
            "example": "Marketing Lead"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Persona description text, or null when none is set",
            "example": "Owns the brand narrative at a mid-market SaaS company"
          },
          "prompt_count": {
            "type": "integer",
            "description": "Number of non-deleted prompts this persona is assigned to. Matches the number of rows GET /api/v1/prompts returns for the same persona.",
            "example": 12
          }
        }
      },
      "PromptTagWithCount": {
        "type": "object",
        "description": "A prompt tag with its prompt count",
        "required": ["id", "name", "prompt_count"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the tag",
            "example": "223e4567-e89b-12d3-a456-426614174111"
          },
          "name": {
            "type": "string",
            "description": "Tag name",
            "example": "Caption Phones"
          },
          "prompt_count": {
            "type": "integer",
            "description": "Number of non-deleted prompts carrying this tag. Matches the number of rows GET /api/v1/prompts returns when filtered by this tag.",
            "example": 12
          }
        }
      },
      "Attribute": {
        "type": "object",
        "description": "A brand-perception attribute (keyword) Athena extracts from AI model responses, such as 'Affordable' or 'Slow Support'.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "example": "Affordable"
          },
          "positive": {
            "type": "boolean",
            "description": "Whether the attribute reads as favourable. This describes the keyword itself, not any individual mention of it: 'Slow Support' is always positive=false, however a given response used it."
          }
        },
        "required": ["id", "name", "positive"]
      },
      "AttributeMetric": {
        "type": "object",
        "properties": {
          "attribute_id": {
            "type": "string",
            "format": "uuid"
          },
          "attribute_name": {
            "type": "string",
            "example": "Affordable"
          },
          "positive": {
            "type": "boolean"
          },
          "response_count": {
            "type": "integer",
            "description": "Number of analyzed responses that mention this attribute."
          },
          "total_responses": {
            "type": "integer",
            "description": "Analyzed responses in the date range \u2014 the denominator."
          },
          "percentage": {
            "type": "number",
            "description": "response_count / total_responses, as a percentage."
          }
        },
        "required": [
          "attribute_id",
          "attribute_name",
          "positive",
          "response_count",
          "total_responses",
          "percentage"
        ]
      },
      "CompetitorAttributeMetric": {
        "type": "object",
        "properties": {
          "competitor_id": {
            "type": "string",
            "format": "uuid"
          },
          "competitor_name": {
            "type": "string",
            "example": "Globex"
          },
          "attribute_id": {
            "type": "string",
            "format": "uuid"
          },
          "attribute_name": {
            "type": "string",
            "example": "Affordable"
          },
          "positive": {
            "type": "boolean"
          },
          "response_count": {
            "type": "integer"
          },
          "total_responses": {
            "type": "integer",
            "description": "Analyzed responses for THIS competitor \u2014 each competitor has its own denominator."
          },
          "percentage": {
            "type": "number"
          }
        },
        "required": [
          "competitor_id",
          "competitor_name",
          "attribute_id",
          "attribute_name",
          "positive",
          "response_count",
          "total_responses",
          "percentage"
        ]
      },
      "AttributeTimeSeriesEntry": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "brand_count": {
            "type": "integer"
          },
          "brand_total": {
            "type": "integer"
          },
          "brand_percentage": {
            "type": "number"
          },
          "competitor_count": {
            "type": "integer"
          },
          "competitor_total": {
            "type": "integer"
          },
          "competitor_percentage": {
            "type": "number"
          }
        },
        "required": [
          "date",
          "brand_count",
          "brand_total",
          "brand_percentage",
          "competitor_count",
          "competitor_total",
          "competitor_percentage"
        ]
      },
      "AttributeMetricsRequest": {
        "type": "object",
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid"
          },
          "positive": {
            "type": "boolean",
            "default": true,
            "description": "Observation direction to select."
          },
          "filters": {
            "$ref": "#/components/schemas/ApiFilters"
          }
        },
        "required": ["website_id", "filters"]
      },
      "AttributeTimeSeriesRequest": {
        "type": "object",
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid"
          },
          "attribute_id": {
            "type": "string",
            "format": "uuid",
            "description": "The attribute to chart. Obtain ids from GET /api/v1/attributes."
          },
          "positive": {
            "type": "boolean",
            "default": true,
            "description": "Observation direction to select."
          },
          "filters": {
            "$ref": "#/components/schemas/ApiFilters"
          }
        },
        "required": ["website_id", "attribute_id", "filters"]
      },
      "ApiFiltersNoCompetitors": {
        "type": "object",
        "description": "The shared filters without competitor_ids, for the brand trait endpoints that do not take it: /api/v1/attributes/cumulative is brand-only, and /api/v1/attributes/observations selects entities with `entity_ids`. Sending competitor_ids is rejected. Use /api/v1/attributes/competitors for per-competitor metrics.",
        "required": ["start_date"],
        "properties": {
          "schedule_id": {
            "$ref": "#/components/schemas/PromptScheduleSelection"
          },
          "start_date": {
            "type": "string",
            "format": "date-time",
            "description": "Filter start date (UTC)",
            "example": "2024-01-01T00:00:00.000Z"
          },
          "end_date": {
            "type": "string",
            "format": "date-time",
            "description": "Filter end date (UTC)",
            "example": "2024-12-31T23:59:59.999Z"
          },
          "models": {
            "type": "array",
            "description": "Filter by AI models",
            "items": {
              "type": "string",
              "enum": [
                "chatgpt",
                "perplexity",
                "gemini",
                "google_ai_overview",
                "copilot",
                "claude",
                "ai_mode",
                "grok",
                "deepseek",
                "meta_ai",
                "mistral"
              ]
            },
            "example": ["chatgpt", "perplexity"]
          },
          "prompt_ids": {
            "type": "array",
            "description": "Filter by specific prompt IDs",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "location_ids": {
            "type": "array",
            "description": "Filter by location IDs. Pass this in the JSON body as `filters.location_ids`, even when filtering by a single location. Use IDs returned by `GET /api/v1/locations`.",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "example": ["123e4567-e89b-12d3-a456-426614174111"]
          },
          "prompt_status": {
            "type": "string",
            "enum": ["active", "paused"],
            "description": "Filter by prompt status"
          },
          "prompt_type": {
            "type": "string",
            "enum": ["branded", "non_branded"],
            "description": "Filter by prompt type"
          }
        },
        "additionalProperties": false
      },
      "CumulativeAttributeMetricsRequest": {
        "type": "object",
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid"
          },
          "positive": {
            "type": "boolean",
            "default": true,
            "description": "Observation direction to select."
          },
          "filters": {
            "$ref": "#/components/schemas/ApiFiltersNoCompetitors"
          }
        },
        "required": ["website_id", "filters"]
      },
      "AttributeObservationsRequest": {
        "type": "object",
        "properties": {
          "website_id": {
            "type": "string",
            "format": "uuid"
          },
          "filters": {
            "$ref": "#/components/schemas/ApiFiltersNoCompetitors"
          },
          "entity_ids": {
            "type": "array",
            "maxItems": 100,
            "description": "Entities to return observations for: the `website_id` for your brand, or competitor ids from `GET /api/v1/competitors`. Omit for every entity.",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "attribute_ids": {
            "type": "array",
            "maxItems": 100,
            "description": "Attributes to return observations for, from `GET /api/v1/attributes`. Omit for every active attribute.",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "positive": {
            "type": "boolean",
            "description": "`true` for favorable observations only, `false` for critical ones only. Omit for both directions."
          },
          "sort": {
            "type": "string",
            "enum": ["intensity", "recent"],
            "default": "intensity",
            "description": "`intensity`: strongest first, unscored last, then newest. `recent`: newest first."
          },
          "page_num": {
            "type": "integer",
            "minimum": 0,
            "default": 0,
            "description": "Zero-indexed page number."
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 40,
            "description": "Rows per page."
          }
        },
        "required": ["website_id", "filters"]
      },
      "AttributeObservation": {
        "type": "object",
        "description": "One brand trait observation: what one AI response said about one entity for one attribute.",
        "properties": {
          "observation_id": {
            "type": "string",
            "format": "uuid"
          },
          "response_id": {
            "type": "string",
            "format": "uuid",
            "description": "The AI response the excerpt comes from."
          },
          "entity_id": {
            "type": "string",
            "format": "uuid",
            "description": "The entity described: your `website_id` for your brand, otherwise a competitor id."
          },
          "entity_name": {
            "type": "string",
            "example": "Acme"
          },
          "is_website": {
            "type": "boolean",
            "description": "`true` when the entity is your brand."
          },
          "attribute_id": {
            "type": "string",
            "format": "uuid"
          },
          "attribute_name": {
            "type": "string",
            "example": "Affordable"
          },
          "positive": {
            "type": "boolean",
            "description": "Whether this observation praises (`true`) or criticizes (`false`) the entity on this attribute."
          },
          "score": {
            "type": ["number", "null"],
            "minimum": -1,
            "maximum": 1,
            "description": "Signed strength from -1 to 1. The sign always matches `positive`; the magnitude (0.1 to 1.0) is how strongly the wording praises or criticizes. `null` when the observation was not scored, because it was extracted before scoring existed or has no valid value. For direction only, use `score ?? (positive ? 1 : -1)`.",
            "example": 0.9
          },
          "text_span": {
            "type": "string",
            "description": "The excerpt of the response that supports the observation."
          },
          "model": {
            "type": "string",
            "description": "AI model that generated the response, as on /api/v1/responses.",
            "example": "chatgpt"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp in UTC, to the second.",
            "example": "2026-09-14T08:21:05Z"
          }
        },
        "required": [
          "observation_id",
          "response_id",
          "entity_id",
          "entity_name",
          "is_website",
          "attribute_id",
          "attribute_name",
          "positive",
          "score",
          "text_span",
          "model",
          "created_at"
        ]
      },
      "BrandFactPillar": {
        "type": ["object", "null"],
        "description": "The published pillar the fact is filed under, or null when the fact is unfiled.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          }
        },
        "required": ["id", "name"]
      },
      "BrandFactSearchResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "text": {
            "type": "string",
            "description": "The fact statement."
          },
          "confidence": {
            "type": ["string", "null"],
            "enum": ["high", "medium", "low", null],
            "description": "Confidence level assigned during ingestion, or null when unrated."
          },
          "source_url": {
            "type": ["string", "null"],
            "description": "URL the fact was extracted from, stored without protocol."
          },
          "source_quote": {
            "type": ["string", "null"],
            "description": "Verbatim quote from the source backing the fact."
          },
          "pillar": {
            "$ref": "#/components/schemas/BrandFactPillar"
          }
        },
        "required": [
          "id",
          "text",
          "confidence",
          "source_url",
          "source_quote",
          "pillar"
        ]
      },
      "BrandFact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "text": {
            "type": "string",
            "description": "The fact statement."
          },
          "status": {
            "type": "string",
            "enum": ["approved", "pending", "rejected"],
            "description": "Review status of the fact."
          },
          "confidence": {
            "type": ["string", "null"],
            "enum": ["high", "medium", "low", null],
            "description": "Confidence level assigned during ingestion, or null when unrated."
          },
          "source_url": {
            "type": ["string", "null"],
            "description": "URL the fact was extracted from, stored without protocol."
          },
          "source_quote": {
            "type": ["string", "null"],
            "description": "Verbatim quote from the source backing the fact."
          },
          "source_type": {
            "type": "string",
            "enum": ["research", "response", "upload", "content_hub"],
            "description": "How the fact entered the Knowledge Base."
          },
          "pillar": {
            "$ref": "#/components/schemas/BrandFactPillar"
          },
          "created_at": {
            "type": "string",
            "description": "ISO 8601 timestamp of when the fact was added."
          }
        },
        "required": [
          "id",
          "text",
          "status",
          "confidence",
          "source_url",
          "source_quote",
          "source_type",
          "pillar",
          "created_at"
        ]
      },
      "KnowledgeBasePillar": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": ["string", "null"]
          },
          "status": {
            "type": "string",
            "enum": ["researching", "published", "draft"],
            "description": "Pillar lifecycle status. Archived pillars are not returned."
          },
          "fact_count": {
            "type": "integer",
            "description": "Number of approved facts filed under the pillar."
          },
          "has_document": {
            "type": "boolean",
            "description": "Whether a synthesized markdown document exists for the pillar."
          },
          "last_researched_at": {
            "type": ["string", "null"],
            "description": "ISO 8601 timestamp of the last research/synthesis pass, or null."
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "status",
          "fact_count",
          "has_document",
          "last_researched_at"
        ]
      },
      "BrandFactIngestOutcome": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer",
            "description": "Position of the fact in the request's facts array."
          },
          "outcome": {
            "type": "string",
            "enum": ["approved", "pending", "duplicate"],
            "description": "What the ingestion pipeline decided. Extensible: new outcome values may be added as the pipeline evolves \u2014 treat unknown values as non-terminal."
          },
          "fact_id": {
            "type": ["string", "null"],
            "description": "The created fact's id; null for duplicates (nothing was inserted)."
          },
          "pillar_id": {
            "type": ["string", "null"],
            "description": "The pillar the fact was filed under (pinned or auto-routed); null when unfiled."
          },
          "matches": {
            "type": "array",
            "description": "Present when the fact was not added because facts already in the Knowledge Base say something similar (outcome is `duplicate`). Review them and resolve with a second call.",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "string" },
                "text": { "type": "string" },
                "status": { "type": "string", "enum": ["pending", "approved"] },
                "source_type": {
                  "type": "string",
                  "enum": ["research", "upload", "content_hub"],
                  "description": "How the fact entered the Knowledge Base: found by research, uploaded, or taken from your content."
                },
                "source_url": { "type": ["string", "null"] },
                "first_party": {
                  "type": ["boolean", "null"],
                  "description": "The source is on your own domains; null when the fact has no source."
                },
                "pillar_id": { "type": ["string", "null"] },
                "pillar_name": { "type": ["string", "null"] },
                "created_at": { "type": "string", "format": "date-time" }
              },
              "required": [
                "id",
                "text",
                "status",
                "source_type",
                "source_url",
                "first_party",
                "pillar_id",
                "pillar_name",
                "created_at"
              ]
            }
          }
        },
        "required": ["index", "outcome", "fact_id", "pillar_id"]
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "API key for authentication. You can create one [here](https://app.athenahq.ai/organization?tab=api)."
      }
    }
  }
}
