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

# Site Diagnostics API: Per-page findings and optimization runs

> Read the latest diagnostics for a brand's pages — scores, outstanding opportunities, and what each page already does well — plus the optimization run behind any one page.

## Overview

The Site Diagnostics API is the page-level view behind Site Optimization. For each audited path it returns the page's AI-visibility scores, the opportunities still open on it, and what it already does well. A second endpoint opens one page's most recent **optimization run** — the block-by-block rewrite Scrunch generated for it.

Where the [Opportunities API](/api-reference/opportunities/overview) ranks work by type across the brand, this API answers the same question one page at a time.

***

## Endpoints

| Method | Path                                              | Purpose                                                           |
| ------ | ------------------------------------------------- | ----------------------------------------------------------------- |
| GET    | `/{brand_id}/site-diagnostics`                    | Latest diagnostics per page, optionally scoped to specific paths. |
| GET    | `/{brand_id}/site-diagnostics/optimization`       | The latest optimization run for one page.                         |
| POST   | `/{brand_id}/site-diagnostics/optimization/apply` | Record that a run was acted on outside Scrunch.                   |

All three require a bearer token. The apply endpoint requires the `optimize` scope; the reads require `query`. See [Authentication](/getting-started/authentication).

***

## Example request

```bash theme={null}
curl -H "Authorization: Bearer $SCRUNCH_API_KEY" \
  "https://api.scrunchai.com/v1/1234/site-diagnostics?path=/about&path=/pricing"
```

```bash theme={null}
curl -H "Authorization: Bearer $SCRUNCH_API_KEY" \
  "https://api.scrunchai.com/v1/1234/site-diagnostics/optimization?path=/pricing"
```

***

## Reading the fields

Three things are easy to get wrong.

<Warning>
  **`path` is required on the optimization endpoint.** Calling `GET /site-diagnostics/optimization` without it returns `422`, not an empty result — there is no "all pages" form of that request. The list endpoint is the opposite: `path` is optional there, and omitting it pages through every audited path.
</Warning>

**Apply records a decision; it does not publish anything.** `POST /optimization/apply` is for changes made *outside* Scrunch — in your CMS, say — so that a run which will never go through Scrunch review is not left looking outstanding. It writes the acknowledgement and returns the run; it does not deploy, and it does not edit your site. Send exactly one of `approve_all: true` or a `reviews` list of per-block verdicts keyed by chunk `id`.

**Only reviewed runs come back by default.** The optimization endpoint returns runs a human accepted — `completed`, `staged`, `deployed`, `acknowledged` — and hides raw unreviewed output. Pass `status` explicitly if you need to see a run that nobody has looked at yet.

<Note>
  Paths are matched exactly, including the leading slash. `?path=/about` and `?path=about` are not the same request, and the second matches nothing.
</Note>


## Related topics

- [Apply Page Optimization](/api-reference/site-diagnostics/apply-page-optimization.md)
- [Get Page Optimization Detail](/api-reference/site-diagnostics/get-page-optimization-detail.md)
- [List Site Diagnostics](/api-reference/site-diagnostics/list-site-diagnostics.md)
