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

# Get Visibility Score

> Get current visibility score AND historical data for charts (combined endpoint)

Returns the current AI visibility score and 6 months of historical data in a single request.

This is the primary endpoint for the dashboard - it provides everything needed for:

* The visibility score card (current score + trend)
* The "Visibility Over Time" chart (historical data)

## Path Parameters

<ParamField path="org_slug" type="string" required>
  The Clerk organization slug
</ParamField>

## Query Parameters

<ParamField query="product_id" type="string">
  Filter by product/item ID. Omit for business-level score.
</ParamField>

<ParamField query="business_url" type="string">
  Business website URL for ranking score fallback (e.g., `https://nike.com`)
</ParamField>

## Response

<ResponseField name="visibilityScore" type="object">
  Current score with trend
</ResponseField>

<ResponseField name="history" type="array">
  Historical data points for charting (up to 6 months)
</ResponseField>

### Visibility Score Object

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| `value` | integer | Current score (0-100)                      |
| `trend` | string  | Week-over-week change (e.g., "+3%", "-2%") |

### History Entry

| Field   | Type    | Description                     |
| ------- | ------- | ------------------------------- |
| `date`  | string  | Formatted date (e.g., "Jul 15") |
| `value` | integer | Score on that date              |

<ResponseExample>
  ```json Response theme={null}
  {
    "visibilityScore": {
      "value": 48,
      "trend": "+3%"
    },
    "history": [
      { "date": "Oct 15", "value": 42 },
      { "date": "Oct 22", "value": 44 },
      { "date": "Oct 29", "value": 45 },
      { "date": "Nov 05", "value": 46 },
      { "date": "Nov 12", "value": 47 },
      { "date": "Nov 19", "value": 48 }
    ]
  }
  ```
</ResponseExample>

## Data Sources & Fallback Logic

**Primary Source:**

| Field             | Table/View                 | Description                   |
| ----------------- | -------------------------- | ----------------------------- |
| `visibilityScore` | `current_visibility_score` | VIEW for fast current lookup  |
| `history`         | `visibility_score_history` | Daily snapshots over 6 months |

**Fallback (before first cron run):**
If `visibility_score_history` is empty and `business_url` is provided, the endpoint falls back to `pre_payment_rankings` table to show an initial score immediately after onboarding.

The fallback returns:

* Score: Value from `pre_payment_rankings` (32-49)
* History: 2 fake data points (yesterday: 0, today: score)

Once the daily cron job completes the first real visibility analysis, the endpoint automatically switches to using the real data from `visibility_score_history`.

## Notes

* Returns 6 months of historical data (once available)
* Score calculated from visibility across all 8 AI platforms
* Trend compares current score to 7 days ago
* **Before first cron run**: Shows pre-payment ranking score (32-49) with fake 2-day history
* **After first cron run**: Switches to real visibility data
* Real visibility analysis runs daily at 14:00 UTC via cron job
