{
  "openapi": "3.1.0",
  "info": {
    "title": "CiteAgentic REST API",
    "version": "1.0.0",
    "description": "Read-only access to AI visibility scores, recommendations and scan history. Five GET endpoints. To start scans or generate content, use the MCP server at POST /mcp.",
    "contact": {
      "name": "CiteAgentic support",
      "email": "support@citeagentic.com"
    }
  },
  "servers": [
    {
      "url": "https://www.citeagentic.com"
    }
  ],
  "externalDocs": {
    "description": "REST API documentation",
    "url": "https://www.citeagentic.com/docs/api/rest"
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "A CiteAgentic API key. The same key authenticates the MCP server. Keys carry scopes; a read endpoint needs the matching read: scope. See https://www.citeagentic.com/docs/api/authentication."
      }
    },
    "schemas": {
      "Brand": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "cadence": {
            "type": "string",
            "description": "How often this brand is scanned."
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/brands": {
      "get": {
        "operationId": "listBrands",
        "summary": "List every brand the key owner can see",
        "description": "Returns owned brands plus any the key owner collaborates on, each with a summary of its latest run.",
        "responses": {
          "200": {
            "description": "The brand list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "brands": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/Brand"
                          },
                          {
                            "type": "object",
                            "properties": {
                              "latestRun": {
                                "type": [
                                  "object",
                                  "null"
                                ]
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "missing_bearer_token — no Authorization header; or invalid_api_key — unknown or revoked key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "tier_disallows_api — the key is valid but the account plan does not include API access.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brands/{id}": {
      "get": {
        "operationId": "getBrand",
        "summary": "Get one brand and its latest run",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The brand id, as returned by GET /api/v1/brands."
          }
        ],
        "responses": {
          "200": {
            "description": "The brand and a summary of its most recent run.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "brand": {
                      "$ref": "#/components/schemas/Brand"
                    },
                    "latestRun": {
                      "type": [
                        "object",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "missing_bearer_token — no Authorization header; or invalid_api_key — unknown or revoked key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "tier_disallows_api — the key is valid but the account plan does not include API access.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The brand does not exist, or the key owner cannot see it. A brand belonging to another account returns 404, not 403.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brands/{id}/visibility": {
      "get": {
        "operationId": "getBrandVisibility",
        "summary": "Get visibility over time",
        "description": "Daily visibility for the brand. Without from/to, returns the default window.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The brand id, as returned by GET /api/v1/brands."
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Start of the window, epoch milliseconds."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "End of the window, epoch milliseconds."
          }
        ],
        "responses": {
          "200": {
            "description": "A daily visibility trend.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "brand": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "trend": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "missing_bearer_token — no Authorization header; or invalid_api_key — unknown or revoked key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "tier_disallows_api — the key is valid but the account plan does not include API access.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The brand does not exist, or the key owner cannot see it. A brand belonging to another account returns 404, not 403.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brands/{id}/recommendations": {
      "get": {
        "operationId": "getBrandRecommendations",
        "summary": "Get the recommendation queue",
        "description": "Each recommendation includes payload.fixPrompt — the paste-ready prompt generated for it.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The brand id, as returned by GET /api/v1/brands."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "open"
            },
            "description": "Filter by status. Defaults to open."
          }
        ],
        "responses": {
          "200": {
            "description": "The recommendation queue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "brand": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "recommendations": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "missing_bearer_token — no Authorization header; or invalid_api_key — unknown or revoked key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "tier_disallows_api — the key is valid but the account plan does not include API access.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The brand does not exist, or the key owner cannot see it. A brand belonging to another account returns 404, not 403.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/brands/{id}/runs": {
      "get": {
        "operationId": "getBrandRuns",
        "summary": "Get scan run history",
        "description": "Returns up to 60 of the most recent runs.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The brand id, as returned by GET /api/v1/brands."
          }
        ],
        "responses": {
          "200": {
            "description": "Recent scan runs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "brand": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "runs": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "missing_bearer_token — no Authorization header; or invalid_api_key — unknown or revoked key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "tier_disallows_api — the key is valid but the account plan does not include API access.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The brand does not exist, or the key owner cannot see it. A brand belonging to another account returns 404, not 403.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}