---
title: "Create GTmetrix reports"
url: https://docs.corefinity.com/api/reference/logs/create-performance-audit-gtmetrix-reports
type: endpoint
last_updated: 2026-11-13
feature: performance-audits
related:
  - https://docs.corefinity.com/guides/tools/performance-audits.md
---
# Create GTmetrix reports

Starts one GTmetrix test for each environment and page of the audit, in the background: read the audit's
GTmetrix reports until `generation.status` is `completed` or `failed`. Each test uses GTmetrix credits, so
send the number it starts as `confirm_count`: any other number is refused with the right number in the
message. When some tests were not started, the next generation at the same location starts only those.

```http
POST /api/performance-audits/{audit}/gtmetrix-reports
```

- Scope: `write`
- Rate limit: 10 a minute
- Long-running: answers with an operation to poll
- Try it in the console: off. It can add to your bill. Copy the request and run it yourself when you are sure.

## Path parameters

- `audit` (integer, required): The id of an audit. Digits only.

## Body

- `confirm_count` (integer, required): The number of tests this starts.
- `location_id` (string, required): The `id` of one of GTmetrix's locations, as the GTmetrix locations list answers it.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/performance-audits/5210/gtmetrix-reports \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "confirm_count": 4,
    "location_id": "2"
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/performance-audits/5210/gtmetrix-reports', [
        'confirm_count' => 4,
        'location_id' => '2',
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/performance-audits/5210/gtmetrix-reports', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    confirm_count: 4,
    location_id: '2',
  }),
});

// 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/performance-audits/5210/gtmetrix-reports",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "confirm_count": 4,
        "location_id": "2",
    },
)

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

## Responses

### 202 The generation is queued.

```json
{
  "audit_id": 5210,
  "error": null,
  "failures": [],
  "finished_at": null,
  "id": "0d9c1a4e-6f1b-4f5e-9b8a-2d7c3e4f5a6b",
  "location_id": "2",
  "reports": [],
  "requested_at": "2026-11-03T12:30:00+00:00",
  "resumed": false,
  "started": 0,
  "status": "queued",
  "tests": 4
}
```

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

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

### 403 The token lacks the `write` scope (`scope_required`).

```json
{
  "code": "scope_required",
  "message": "This access token does not have the destructive scope this needs. Use a token with the destructive scope.",
  "reason": "scope_required",
  "scope": "destructive"
}
```

### 404 The id does not exist, or it is something you cannot see. Both answer the same body.

```json
{
  "message": "Not found."
}
```

### 409 A generation is already queued or running (`run_in_progress`), the audit has no environments or pages (`nothing_to_run`), it has more than 200 environment and page pairs (`too_large`), or two pairs have the same report name (`conflict`). Nothing was started.

```json
{
  "code": "conflict",
  "message": "Two of this audit's environment and page pairs have the same report name, \"Shop Home Home\", and GTmetrix reports are kept by that name. Rename an environment or a page of the audit first. Nothing was started.",
  "reason": "conflict"
}
```

### 422 `confirm_count` is not the number of tests (`confirm_mismatch`), or a field is missing or `location_id` is not one of GTmetrix's locations (`invalid`). Nothing was started.

```json
{
  "code": "confirm_mismatch",
  "errors": {
    "confirm_count": [
      "This starts 4 GTmetrix tests, one for each environment and page, and each uses GTmetrix credits. Send confirm_count 4 to go ahead. Nothing was started."
    ]
  },
  "field": "confirm_count",
  "message": "This starts 4 GTmetrix tests, one for each environment and page, and each uses GTmetrix credits. Send confirm_count 4 to go ahead. Nothing was started.",
  "reason": "confirm_mismatch"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

### 502 GTmetrix refused a request or did not answer (`upstream_unavailable`). Nothing was saved; try again later.

```json
{
  "code": "upstream_unavailable",
  "message": "GTmetrix could not list its locations: GTmetrix request failed (HTTP 500). Try again later.",
  "reason": "upstream_unavailable"
}
```

### 503 GTmetrix reports are not available right now (`temporarily_unavailable`). Nothing was sent.

```json
{
  "code": "temporarily_unavailable",
  "message": "GTmetrix reports are not available right now. Try again later.",
  "reason": "temporarily_unavailable"
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 404 |  | Check the id. You see only what your account can reach. |
| 409 | `conflict` | The action conflicts with the object's present state. Read the message. |
| 409 | `nothing_to_run` | The audit has no domains or pages to test. Add them to the audit first. |
| 409 | `run_in_progress` | The audit is running. Wait for it to finish. |
| 409 | `too_large` | The upload is larger than the limit for one file. |
| 422 | `confirm_mismatch` | Send the confirmation exactly as the field named in `field` asks for it. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 502 | `upstream_unavailable` | A service the action depends on did not answer. Try again later. |
| 503 | `temporarily_unavailable` | The Control Panel could not answer just now. Nothing was started; try again shortly. |

## The same task elsewhere

- Guide: [Performance audits](https://docs.corefinity.com/guides/tools/performance-audits.md)
