---
title: "Start a PageSpeed test"
url: https://docs.corefinity.com/api/reference/logs/start-site-page-speed-run
type: endpoint
last_updated: 2026-11-13
feature: pagespeed
related:
  - https://docs.corefinity.com/guides/sites/logs-and-monitoring/pagespeed.md
  - https://docs.corefinity.com/mcp/tools/corestack_pagespeed_run.md
---
# Start a PageSpeed test

Queues a mobile and a desktop test of the site's home page; read the history again for the results, which are
in once the tests have left `in_flight`. A site can start two tests an hour, only while it is live, and
Corefinity keeps a daily budget of tests for everyone.

```http
POST /api/corestack/sites/{site}/pagespeed/runs
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 10 a minute; 2 an hour for each environment
- Long-running: answers with an operation to poll
- Try it in the console: off. It has not been cleared for the console. Copy the request and run it yourself when you are sure.

## Path parameters

- `site` (integer, required): The id of a site row. A website's production site and each of its environments has its own id. Digits only.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/pagespeed/runs \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json"
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/pagespeed/runs');

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/pagespeed/runs', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
  },
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.post(
    "https://manage.corefinity.com/api/corestack/sites/1042/pagespeed/runs",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
)

data = res.json() if res.content else None
```

## Responses

### 202 Both tests are queued.

```json
{
  "runs": [
    {
      "created_at": "2026-11-10T13:00:00Z",
      "diagnostics": null,
      "error": null,
      "fetched_at": null,
      "field": null,
      "finished_at": null,
      "id": 6207,
      "lighthouse_version": null,
      "metrics": {
        "cls": {
          "band": null,
          "value": null
        },
        "fcp": {
          "band": null,
          "value_ms": null
        },
        "inp": {
          "band": null,
          "source": null,
          "value_ms": null
        },
        "lcp": {
          "band": null,
          "value_ms": null
        },
        "speed_index": {
          "band": null,
          "value_ms": null
        },
        "tbt": {
          "band": null,
          "value_ms": null
        },
        "ttfb": {
          "band": null,
          "value_ms": null
        }
      },
      "opportunities": [],
      "requested_by": {
        "id": 2042,
        "name": "Tom Harbour"
      },
      "score": {
        "band": null,
        "value": null
      },
      "started_at": null,
      "status": "queued",
      "status_label": "Queued",
      "strategy": "mobile",
      "url": "https://harbourandfinch.example.com/"
    },
    {
      "created_at": "2026-11-10T13:00:00Z",
      "diagnostics": null,
      "error": null,
      "fetched_at": null,
      "field": null,
      "finished_at": null,
      "id": 6208,
      "lighthouse_version": null,
      "metrics": {
        "cls": {
          "band": null,
          "value": null
        },
        "fcp": {
          "band": null,
          "value_ms": null
        },
        "inp": {
          "band": null,
          "source": null,
          "value_ms": null
        },
        "lcp": {
          "band": null,
          "value_ms": null
        },
        "speed_index": {
          "band": null,
          "value_ms": null
        },
        "tbt": {
          "band": null,
          "value_ms": null
        },
        "ttfb": {
          "band": null,
          "value_ms": null
        }
      },
      "opportunities": [],
      "requested_by": {
        "id": 2042,
        "name": "Tom Harbour"
      },
      "score": {
        "band": null,
        "value": null
      },
      "started_at": null,
      "status": "queued",
      "status_label": "Queued",
      "strategy": "desktop",
      "url": "https://harbourandfinch.example.com/"
    }
  ]
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the scope (`scope_required`, with the `scope` to use), your company requires two-factor authentication and you have not set it up, or your account has no company that can use Managed Clusters, for example because the company was closed (`company_unavailable` or `company_not_enabled`, whichever the route checks first). For Managed Clusters routes; any other route uses `ForbiddenScopeOrTwoFactor`.

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist or is something you cannot see, or the feature is not on for your company (`feature_off`).

```json
{
  "code": "feature_off",
  "message": "Not found.",
  "reason": "feature_off"
}
```

### 409 A test is already queued or running for the site (`busy`), the site is not live yet (`preview_only`), or it is deleted (`deleted`), removed (`removed`) or still being created (`provisioning`).

```json
{
  "code": "busy",
  "message": "A PageSpeed test is already running for this site.",
  "reason": "busy"
}
```

### 422 The site is in maintenance mode (`maintenance`): tests resume when it is switched off.

```json
{
  "code": "maintenance",
  "message": "In maintenance mode; tests resume when it is switched off.",
  "reason": "maintenance"
}
```

### 429 Too many requests in a minute, two tests this hour already, or today's budget is used up. All are `rate_limited` and send `Retry-After`; the last two say when a test is possible again in `next_at`.

```json
{
  "code": "rate_limited",
  "message": "Today's PageSpeed budget is used up. Try again tomorrow.",
  "next_at": "2026-11-11T00:00:00Z",
  "reason": "rate_limited"
}
```

### 503 Corefinity has switched PageSpeed tests off for the moment (`switched_off`). Try again later.

```json
{
  "code": "switched_off",
  "message": "PageSpeed Insights is switched off",
  "reason": "switched_off"
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 404 | `feature_off` | This feature is not on for your organisation yet. |
| 409 | `busy` | Another operation is running on the site. Wait for it to finish. |
| 409 | `deleted` | The site, environment or copy has been deleted, or is being deleted. Nothing can be changed on it. Restore a deleted site first if it can still be restored. |
| 409 | `preview_only` | The environment has no domain attached yet. Attach one first. |
| 409 | `provisioning` | The site is still being created. Try again in a few minutes. |
| 409 | `removed` | The site or environment is being removed, or has been. Nothing can be changed on it. |
| 422 | `maintenance` | The site is in maintenance mode, which blocks this. Switch maintenance mode off first. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 503 | `switched_off` | Corefinity has switched this action off for the moment. Try again later. |

## The same task elsewhere

- Guide: [PageSpeed](https://docs.corefinity.com/guides/sites/logs-and-monitoring/pagespeed.md)
- MCP tool: [`corestack_pagespeed_run`](https://docs.corefinity.com/mcp/tools/corestack_pagespeed_run.md)
