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

Creates an audit and starts its first run: each page of each environment is loaded `number_of_requests` times
from the server location, uncached and, where `check_cache` is set, cached as well. The answer is the audit
with `run.status` `queued`; read the audit until `run.status` is `completed` or `failed`.

```http
POST /api/performance-audits
```

- Scope: `write`
- Rate limit: 10 a minute
- 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.

## Body

- `domains` (array of objects, required): The environments to test.
  - `environment` (string, required): A name for the environment, unique in the audit, such as `Current host`. No control characters.
  - `http_password` (string or null): The HTTP authentication password. No control characters. Never answered.
  - `http_username` (string or null): The HTTP authentication username that opens a protected site for the runs. No control characters. Never answered.
  - `url` (string, required): The address it is served on, a full `http` or `https` URL. No control characters.
- `name` (string, required)
- `number_of_requests` (integer): How many times each page is loaded. Defaults to `5`.
- `page_types` (array of objects, required): The pages to test on each environment.
  - `check_cache` (boolean): Also test the page cached.
  - `path` (string or null): The path of the page, such as `/shop/`. No control characters.
  - `title` (string, required): A name for the page, unique in the audit. No control characters.
- `server_location` (integer): The id of the server location to test from, as an audit answers it in `server_location.id`. The first location when left out.
- `user_agent` (string): The user agent the requests carry. No control characters. The Control Panel's own when left out.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/performance-audits \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "domains": [
      {
        "environment": "Current host",
        "url": "https://old.harbourandfinch.example.org"
      },
      {
        "environment": "Corefinity",
        "http_password": "made-up-preview-password",
        "http_username": "preview",
        "url": "https://harbourandfinch-example-com.northwind.cfstack.example.net"
      }
    ],
    "name": "Shop audit",
    "number_of_requests": 5,
    "page_types": [
      {
        "check_cache": true,
        "path": "/",
        "title": "Home"
      },
      {
        "path": "/shop/",
        "title": "Category"
      }
    ]
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/performance-audits', [
        'domains' => [
            [
                'environment' => 'Current host',
                'url' => 'https://old.harbourandfinch.example.org',
            ],
            [
                'environment' => 'Corefinity',
                'http_password' => 'made-up-preview-password',
                'http_username' => 'preview',
                'url' => 'https://harbourandfinch-example-com.northwind.cfstack.example.net',
            ],
        ],
        'name' => 'Shop audit',
        'number_of_requests' => 5,
        'page_types' => [
            [
                'check_cache' => true,
                'path' => '/',
                'title' => 'Home',
            ],
            [
                'path' => '/shop/',
                'title' => 'Category',
            ],
        ],
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/performance-audits', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    domains: [
      {
        environment: 'Current host',
        url: 'https://old.harbourandfinch.example.org',
      },
      {
        environment: 'Corefinity',
        http_password: 'made-up-preview-password',
        http_username: 'preview',
        url: 'https://harbourandfinch-example-com.northwind.cfstack.example.net',
      },
    ],
    name: 'Shop audit',
    number_of_requests: 5,
    page_types: [
      {
        check_cache: true,
        path: '/',
        title: 'Home',
      },
      {
        path: '/shop/',
        title: 'Category',
      },
    ],
  }),
});

// 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",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "domains": [
            {
                "environment": "Current host",
                "url": "https://old.harbourandfinch.example.org",
            },
            {
                "environment": "Corefinity",
                "http_password": "made-up-preview-password",
                "http_username": "preview",
                "url": "https://harbourandfinch-example-com.northwind.cfstack.example.net",
            },
        ],
        "name": "Shop audit",
        "number_of_requests": 5,
        "page_types": [
            {
                "check_cache": True,
                "path": "/",
                "title": "Home",
            },
            {
                "path": "/shop/",
                "title": "Category",
            },
        ],
    },
)

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

## Responses

### 202 The audit was created and its run is queued.

```json
{
  "company_id": 1204,
  "created_at": "2026-11-03T12:30:00+00:00",
  "domains": [
    {
      "environment": "Current host",
      "http_auth": false,
      "url": "https://old.harbourandfinch.example.org"
    },
    {
      "environment": "Corefinity",
      "http_auth": true,
      "url": "https://harbourandfinch-example-com.northwind.cfstack.example.net"
    }
  ],
  "id": 5211,
  "name": "Shop audit",
  "number_of_requests": 5,
  "page_types": [
    {
      "check_cache": true,
      "path": "/",
      "title": "Home"
    },
    {
      "check_cache": false,
      "path": "/shop/",
      "title": "Category"
    }
  ],
  "report": {
    "frozen_at": null,
    "legacy_link_live": false,
    "password_protected": false,
    "revoked_at": null,
    "sections": [
      {
        "enabled": true,
        "key": "hero",
        "label": "Headline",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "at_a_glance",
        "label": "At a glance",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "response_times",
        "label": "Response times",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "gap",
        "label": "The gap, measurement by measurement",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "improvement",
        "label": "Improvement per measurement",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "absolute_times",
        "label": "Absolute times, side by side",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "waterfall",
        "label": "Where the time actually goes",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "filmstrip",
        "label": "Loading filmstrip",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "full_table",
        "label": "The full table",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "google_scores",
        "label": "Google scores",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "definitions",
        "label": "Definitions",
        "tab": "simple"
      },
      {
        "enabled": true,
        "key": "method",
        "label": "Method",
        "tab": "technical"
      },
      {
        "enabled": true,
        "key": "timing_breakdown",
        "label": "Timing breakdown",
        "tab": "technical"
      },
      {
        "enabled": true,
        "key": "samples",
        "label": "Individual samples",
        "tab": "technical"
      },
      {
        "enabled": true,
        "key": "status_codes",
        "label": "Status codes and redirect chains",
        "tab": "technical"
      },
      {
        "enabled": true,
        "key": "response_headers",
        "label": "Response headers",
        "tab": "technical"
      },
      {
        "enabled": true,
        "key": "raw_lighthouse_json",
        "label": "Raw Lighthouse response",
        "tab": "technical"
      },
      {
        "enabled": true,
        "key": "all_metrics",
        "label": "Every available metric",
        "tab": "technical"
      },
      {
        "enabled": true,
        "key": "cta",
        "label": "Contact Corefinity",
        "tab": "both"
      }
    ],
    "shared": false,
    "shared_at": null,
    "username": null
  },
  "run": {
    "error": null,
    "finished_at": null,
    "requested_at": "2026-11-03T12:30:00+00:00",
    "started_at": null,
    "status": "queued"
  },
  "server_location": {
    "id": 12,
    "name": "London"
  },
  "updated_at": "2026-11-03T12:30:00+00:00",
  "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36"
}
```

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

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

### 403 The token lacks the `write` scope (`scope_required`), or your account cannot create performance audits (`forbidden`).

```json
{
  "code": "forbidden",
  "message": "Your account cannot create performance audits. Ask an owner of your company for access.",
  "reason": "forbidden"
}
```

### 409 The server location cannot run tests any more (`location_gone`). The audit was created, and no run was queued: find it in the list, choose another server location for it, then start a run.

```json
{
  "code": "location_gone",
  "message": "This audit's server location no longer exists. Choose another server location for the audit first.",
  "reason": "location_gone"
}
```

### 422 A field is missing or wrong. `field` names the first one.

```json
{
  "code": "invalid",
  "errors": {
    "domains": [
      "The domains field is required."
    ]
  },
  "field": "domains",
  "message": "The domains field is required.",
  "reason": "invalid"
}
```

### 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
}
```

### 503 Audits cannot run right now (`temporarily_unavailable`). Nothing was saved.

```json
{
  "code": "temporarily_unavailable",
  "message": "Performance audits cannot run 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 | `forbidden` | The person is not allowed to do this. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 409 | `location_gone` | The audit's server location no longer exists. Choose another location for the audit. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 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)
