> ## Documentation Index
> Fetch the complete documentation index at: https://docs.athenahq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Saved view exports

> Pull the metrics of a dashboard saved view into Snowflake, BigQuery, or any warehouse on a schedule

AthenaHQ does not ship a native warehouse connector. To keep a warehouse table in step with a saved view, run a scheduled job on your side that asks the metrics endpoints for that view and a date range, then writes the result to your warehouse. The endpoints apply the view's filters the way the dashboard does, so the numbers match what the dashboard shows for the same view and dates.

## Prerequisites

* An AthenaHQ API key with access to the website (Organization → API tab). See the [Authentication](/api-reference/authentication) page. A dedicated key scoped to this one website is the safest choice for a scheduled job.
* The `website_id` you want to report on. Fetch it with `GET /api/v1/websites`.
* A saved view on that website, created in the dashboard.

## Setup

<Steps>
  <Step title="Find the saved view's id">
    ```bash theme={null}
    curl "https://api.athenahq.ai/api/v1/saved-views?website_id=YOUR_WEBSITE_ID" \
      -H "x-api-key: YOUR_API_KEY"
    ```

    Copy the `id` of the view whose `name` you want. The id stays the same when someone edits the view in the dashboard, so the export follows those edits.
  </Step>

  <Step title="Request a month of metrics for the view">
    ```bash theme={null}
    curl -X POST https://api.athenahq.ai/api/v1/metrics/mention-rate/cumulative \
      -H "x-api-key: YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "website_id": "YOUR_WEBSITE_ID",
        "filters": {
          "saved_view_id": "YOUR_SAVED_VIEW_ID",
          "start_date": "2026-08-01",
          "end_date": "2026-08-31"
        }
      }'
    ```

    The response has one entry per brand: yours (`is_self: true`) and each competitor the view selects.

    ```json theme={null}
    {
      "data": {
        "Your Brand": { "mention_rate": 42.3, "relative_mention_rate": 61.8, "is_self": true },
        "Competitor A": { "mention_rate": 24.9, "relative_mention_rate": 36.4, "is_self": false }
      }
    }
    ```
  </Step>

  <Step title="Schedule it">
    Run the request once a month for the month that just ended and append the rows, with the month, to your table. For example, in Python:

    ```python theme={null}
    import datetime as dt

    import requests

    today = dt.date.today()
    end = today.replace(day=1) - dt.timedelta(days=1)  # last day of last month
    start = end.replace(day=1)

    response = requests.post(
        "https://api.athenahq.ai/api/v1/metrics/mention-rate/cumulative",
        headers={"x-api-key": API_KEY},
        json={
            "website_id": WEBSITE_ID,
            "filters": {
                "saved_view_id": SAVED_VIEW_ID,
                "start_date": start.isoformat(),
                "end_date": end.isoformat(),
            },
        },
        timeout=60,
    )
    response.raise_for_status()

    rows = [
        {"month": start.isoformat(), "brand": name, **values}
        for name, values in response.json()["data"].items()
    ]
    # Write `rows` to your warehouse table, e.g. with the Snowflake connector's
    # write_pandas or an INSERT through your usual loading tool.
    ```
  </Step>
</Steps>

## Which number matches the dashboard

The dashboard's Mention Rate card shows the **relevant** rate by default. In the API that is `relative_mention_rate`: mentions of the brand divided by the responses that mention your brand or one of the view's competitors. `mention_rate` is the card's **absolute** mode: mentions divided by every response in the view. Read the entry with `is_self: true` for your own brand.

Because the relevant rate counts responses that mention any of the view's competitors, changing the view's competitor list changes your own relevant rate too, both in the dashboard and here.

## How the view is applied

* **Dates.** `start_date` and `end_date` decide the window; the date range saved with the view is ignored. Send plain dates (`YYYY-MM-DD`). `end_date` is inclusive.
* **Defaults.** Like the dashboard, the view counts active prompts only and every model, unless the view says otherwise. A request without `saved_view_id` keeps the API's own defaults, which include paused prompts.
* **Overrides.** Any filter you send next to `saved_view_id` replaces the view's value for that field. For example, `"models": ["chatgpt"]` reads the view for ChatGPT only.
* **Other pages' filters.** A saved view is shared with the Prompts, Responses and Sources pages. Filters that only those pages use, such as sentiment or source tags, do not change metrics in the dashboard, and they do not change them here.
* **Every metric.** The same `saved_view_id` works on all the metrics endpoints: mention rate, share of voice, citation rate and position, cumulative and time series. The MCP metric tools (`get_mention_rate_cumulative` and the others) take it too.

## Errors

| Status | Meaning | What to do |
| - | - | - |
| `404` Saved view not found | The id is not a saved view of `website_id`. | List the website's views again; the view may have been deleted. |
| `400` Saved view "…" uses filters the API cannot apply | The view uses a filter the API cannot reproduce, such as a "Models is not any of" filter. The message names it. | Send the named filter explicitly (for example `filters.models`) to replace the view's value, or change the view in the dashboard. |
