> ## 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.

# Materialize Score

<Note>
  **Internal Service** — This is not an HTTP endpoint. It's called directly by the `generate-all` orchestrator.
</Note>

## Purpose

Copies the pre-payment ranking score to the `visibility_score_history` table. This preserves the initial score so users can see their progress over time.

Runs in **GROUP 1f** (parallel with scrape, fire-and-forget). Doesn't need scraped pages.

## Function Signature

```python theme={null}
async def run_materialize_score(url: str, org_slug: str) -> StepResult
```

## Parameters

| Parameter  | Type  | Description                 |
| ---------- | ----- | --------------------------- |
| `url`      | `str` | The website URL             |
| `org_slug` | `str` | The Clerk organization slug |

## Returns

```json theme={null}
{
  "name": "materialize_score",
  "status": "success",
  "data": {
    "score": 72,
    "entity_id": "uuid-..."
  }
}
```

## What It Does

1. Fetches the pre-payment ranking score from the ranking database
2. Creates a history entry in `visibility_score_history`
3. This becomes the "Day 0" baseline for tracking improvement

## Database Schema

```sql theme={null}
INSERT INTO visibility_score_history (
  entity_id,
  score,
  recorded_at
) VALUES (
  'uuid-...',
  72,
  NOW()
);
```

## Code Location

```
src/app/apis/onboarding/generate_all/
├── scoring.py          # materialize_score function
└── tasks/
    └── scoring.py      # run_materialize_score task wrapper
```
