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

# GTmetrix API reference

> API reference for the GTmetrix plugin in Corsair: every `gtmetrix.api.*` operation with its input and output types, taken from the plugin's Zod schemas.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Browsers

### get

`browsers.get`

Get one browser and the test features it supports.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.browsers.get({ browserId: '3' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `browserId` | `string` | Yes | Browser id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     browser?: string | null,
>     platform?: string | null,
>     device?: string | null,
>     adblock?: boolean | null,
>     lighthouse?: boolean | null,
>     cookies?: boolean | null,
>     filtering?: boolean | null,
>     http_auth?: boolean | null,
>     throttle?: boolean | null,
>     video?: boolean | null,
>     dns?: boolean | null,
>     user_agent?: boolean | null,
>     resolution?: boolean | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### list

`browsers.list`

List the browsers tests can run in, with the features each supports (Lighthouse, video, throttling, custom DNS).

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.browsers.list({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     browser?: string | null,
>     platform?: string | null,
>     device?: string | null,
>     adblock?: boolean | null,
>     lighthouse?: boolean | null,
>     cookies?: boolean | null,
>     filtering?: boolean | null,
>     http_auth?: boolean | null,
>     throttle?: boolean | null,
>     video?: boolean | null,
>     dns?: boolean | null,
>     user_agent?: boolean | null,
>     resolution?: boolean | null
>   } | null,
>   links?: Record<string, any> | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

## Locations

### get

`locations.get`

Get one test location.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.locations.get({ locationId: '24' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `locationId` | `string` | Yes | Location id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     region?: string | null,
>     region_sort_order?: number | null,
>     default?: boolean | null,
>     account_has_access?: boolean | null,
>     browsers?: string[] | null,
>     ips?: string[] | null,
>     servers?: number | null,
>     active_location?: boolean | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### list

`locations.list`

List test locations with their region, browsers and whether this account can use them.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.locations.list({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     region?: string | null,
>     region_sort_order?: number | null,
>     default?: boolean | null,
>     account_has_access?: boolean | null,
>     browsers?: string[] | null,
>     ips?: string[] | null,
>     servers?: number | null,
>     active_location?: boolean | null
>   } | null,
>   links?: Record<string, any> | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

## Pages

### alertConditions

`pages.alertConditions`

Get a page's performance alert conditions and recipients.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pages.alertConditions({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     create_video?: boolean | null,
>     conditions?: {
>       metric?: string | null,
>       operator?: string | null,
>       value?: number | null
>     }[] | null,
>     send_to?: {
>       email?: string | null,
>       channel?: string | null
>     }[] | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### alertEvents

`pages.alertEvents`

List the performance alerts a page has triggered, newest first.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pages.alertEvents({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |
| `page` | `number` | No | Page number (1-based). |
| `pageSize` | `number` | No | Results per page, up to 500. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     timestamp?: number | null,
>     report_id?: string | null,
>     alerts?: {
>       metric?: string | null,
>       operator?: string | null,
>       threshold?: number | null,
>       value?: number | null,
>       error?: string | null,
>       error_slug?: string | null
>     }[] | null,
>     recipient_emails?: string[] | null
>   } | null,
>   links?: Record<string, any> | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

### attachTags

`pages.attachTags`

Attach page tags to a page.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pages.attachTags({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |
| `tagIds` | `string[]` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     created?: number | null,
>     browser?: string | null,
>     location?: string | null,
>     latest_report?: string | null,
>     latest_report_time?: number | null,
>     report_count?: number | null,
>     monitored?: string | null,
>     page_tags?: string[] | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### delete

`pages.delete`

Delete a page and its reports permanently.

**Risk:** `destructive`

```ts theme={null}
await corsair.gtmetrix.api.pages.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### deleteAlertConditions

`pages.deleteAlertConditions`

Remove all of a page's performance alert conditions.

**Risk:** `destructive`

```ts theme={null}
await corsair.gtmetrix.api.pages.deleteAlertConditions({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### detachTags

`pages.detachTags`

Detach page tags from a page.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pages.detachTags({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |
| `tagIds` | `string[]` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     created?: number | null,
>     browser?: string | null,
>     location?: string | null,
>     latest_report?: string | null,
>     latest_report_time?: number | null,
>     report_count?: number | null,
>     monitored?: string | null,
>     page_tags?: string[] | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### get

`pages.get`

Get a page: URL, latest report, report count, monitoring frequency and tags.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pages.get({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     created?: number | null,
>     browser?: string | null,
>     location?: string | null,
>     latest_report?: string | null,
>     latest_report_time?: number | null,
>     report_count?: number | null,
>     monitored?: string | null,
>     page_tags?: string[] | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### latestReport

`pages.latestReport`

Get a page's latest report.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pages.latestReport({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     test?: string | null,
>     source?: string | null,
>     page_tags?: string[] | null,
>     browser?: string | null,
>     location?: string | null,
>     created?: number | null,
>     expires?: number | null,
>     gtmetrix_grade?: string | null,
>     gtmetrix_score?: number | null,
>     performance_score?: number | null,
>     structure_score?: number | null,
>     pagespeed_score?: number | null,
>     yslow_score?: number | null,
>     html_bytes?: number | null,
>     page_bytes?: number | null,
>     page_requests?: number | null,
>     redirect_duration?: number | null,
>     connect_duration?: number | null,
>     backend_duration?: number | null,
>     time_to_first_byte?: number | null,
>     first_paint_time?: number | null,
>     first_contentful_paint?: number | null,
>     dom_interactive_time?: number | null,
>     dom_content_loaded_time?: number | null,
>     dom_content_loaded_duration?: number | null,
>     onload_time?: number | null,
>     onload_duration?: number | null,
>     fully_loaded_time?: number | null,
>     rum_speed_index?: number | null,
>     speed_index?: number | null,
>     largest_contentful_paint?: number | null,
>     time_to_interactive?: number | null,
>     total_blocking_time?: number | null,
>     cumulative_layout_shift?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### list

`pages.list`

List pages (URLs with at least one report), with paging, sorting and filters (url, monitored, page\_tag).

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pages.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `page` | `number` | No | Page number (1-based). |
| `pageSize` | `number` | No | Results per page, up to 500. |
| `sort` | `string` | No | Comma-separated attributes to sort by; prefix `-` for descending (`-created`). |
| `filter` | `Record<string, string \| number \| (string \| number)[]>` | No | Filters by attribute, with an optional operator suffix: `{ "state": "completed" }`, `{ "created:gt": 1617680457 }`, `{ ":bool": "OR" }`. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> (
>   {
>     data: {
>       type?: string | null,
>       id?: string | null,
>       attributes?: {
>         url?: string | null,
>         created?: number | null,
>         browser?: string | null,
>         location?: string | null,
>         latest_report?: string | null,
>         latest_report_time?: number | null,
>         report_count?: number | null,
>         monitored?: string | null,
>         page_tags?: string[] | null
>       } | null,
>       links?: Record<string, any> | null
>     }
>   } | {
>     type?: string | null,
>     id?: string | null,
>     attributes?: {
>       url?: string | null,
>       created?: number | null,
>       browser?: string | null,
>       location?: string | null,
>       latest_report?: string | null,
>       latest_report_time?: number | null,
>       report_count?: number | null,
>       monitored?: string | null,
>       page_tags?: string[] | null
>     } | null,
>     links?: Record<string, any> | null
>   }
> )[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

### performanceMonitor

`pages.performanceMonitor`

Set a page's monitoring frequency (hourly, daily, weekly, monthly) or turn it off. Scheduled tests use the account's monitoring allowance.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pages.performanceMonitor({ pageId: '<page id>', frequency: 'weekly' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |
| `frequency` | `no \| none \| hourly \| daily \| weekly \| monthly` | Yes | `no`/`none` turns monitoring off; hourly may need a paid plan. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     created?: number | null,
>     browser?: string | null,
>     location?: string | null,
>     latest_report?: string | null,
>     latest_report_time?: number | null,
>     report_count?: number | null,
>     monitored?: string | null,
>     page_tags?: string[] | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### reports

`pages.reports`

List a page's reports, with paging, sorting and filters.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pages.reports({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |
| `page` | `number` | No | Page number (1-based). |
| `pageSize` | `number` | No | Results per page, up to 500. |
| `sort` | `string` | No | Comma-separated attributes to sort by; prefix `-` for descending (`-created`). |
| `filter` | `Record<string, string \| number \| (string \| number)[]>` | No | Filters by attribute, with an optional operator suffix: `{ "state": "completed" }`, `{ "created:gt": 1617680457 }`, `{ ":bool": "OR" }`. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     test?: string | null,
>     source?: string | null,
>     page_tags?: string[] | null,
>     browser?: string | null,
>     location?: string | null,
>     created?: number | null,
>     expires?: number | null,
>     gtmetrix_grade?: string | null,
>     gtmetrix_score?: number | null,
>     performance_score?: number | null,
>     structure_score?: number | null,
>     pagespeed_score?: number | null,
>     yslow_score?: number | null,
>     html_bytes?: number | null,
>     page_bytes?: number | null,
>     page_requests?: number | null,
>     redirect_duration?: number | null,
>     connect_duration?: number | null,
>     backend_duration?: number | null,
>     time_to_first_byte?: number | null,
>     first_paint_time?: number | null,
>     first_contentful_paint?: number | null,
>     dom_interactive_time?: number | null,
>     dom_content_loaded_time?: number | null,
>     dom_content_loaded_duration?: number | null,
>     onload_time?: number | null,
>     onload_duration?: number | null,
>     fully_loaded_time?: number | null,
>     rum_speed_index?: number | null,
>     speed_index?: number | null,
>     largest_contentful_paint?: number | null,
>     time_to_interactive?: number | null,
>     total_blocking_time?: number | null,
>     cumulative_layout_shift?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

### retest

`pages.retest`

Run a new test with a page's settings. Spends API credits like tests.start.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pages.retest({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     report?: string | null,
>     source?: string | null,
>     location?: string | null,
>     browser?: string | null,
>     state?: string | null,
>     error?: string | null,
>     created?: number | null,
>     started?: number | null,
>     finished?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### updateAlertConditions

`pages.updateAlertConditions`

Replace a page's performance alert conditions (up to 10) and, for Team organizations, the recipients.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pages.updateAlertConditions({
	pageId: '<page id>',
	conditions: [{ metric: 'largest_contentful_paint', operator: '>', value: 2500 }],
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageId` | `string` | Yes | Page id from GTmetrix. |
| `conditions` | `object[]` | Yes | The full list (replaces the current one); \[] removes all. |
| `create_video` | `boolean` | No | — |
| `send_to` | `object[]` | No | Team organizations only, where it is required. |

Replaces the whole list (up to 10). `send_to` is required for Team
organizations and refused for everyone else.

> [accordion] conditions full type
>
> ```ts theme={null}
> {
>   metric: string,
>   operator: < | = |>,
>   value: number
> }[]
> ```

> [accordion] send\_to full type
>
> ```ts theme={null}
> {
>   email: string,
>   channel?: email
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     create_video?: boolean | null,
>     conditions?: {
>       metric?: string | null,
>       operator?: string | null,
>       value?: number | null
>     }[] | null,
>     send_to?: {
>       email?: string | null,
>       channel?: string | null
>     }[] | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

## Page Tags

### attachPages

`pageTags.attachPages`

Attach a page tag to pages.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pageTags.attachPages({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tagId` | `string` | Yes | Page tag id from GTmetrix. |
| `pageIds` | `string[]` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     description?: string | null,
>     color?: string | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### create

`pageTags.create`

Create a page tag (name, description, colour).

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pageTags.create({ name: 'production', color: 'FF8800' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | Tag name, unique per account. |
| `description` | `string` | No | — |
| `color` | `string` | No | Hex colour without `#` (`FF8800`). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     description?: string | null,
>     color?: string | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### delete

`pageTags.delete`

Delete a page tag; it is detached from every page.

**Risk:** `destructive`

```ts theme={null}
await corsair.gtmetrix.api.pageTags.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tagId` | `string` | Yes | Page tag id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### detachPages

`pageTags.detachPages`

Detach a page tag from pages.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pageTags.detachPages({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tagId` | `string` | Yes | Page tag id from GTmetrix. |
| `pageIds` | `string[]` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     description?: string | null,
>     color?: string | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### get

`pageTags.get`

Get one page tag.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pageTags.get({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tagId` | `string` | Yes | Page tag id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     description?: string | null,
>     color?: string | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### list

`pageTags.list`

List the page tags on this account.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.pageTags.list({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     description?: string | null,
>     color?: string | null
>   } | null,
>   links?: Record<string, any> | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

### update

`pageTags.update`

Change a page tag's name, description or colour.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.pageTags.update({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tagId` | `string` | Yes | Page tag id from GTmetrix. |
| `name` | `string` | No | Tag name, unique per account. |
| `description` | `string` | No | — |
| `color` | `string` | No | Hex colour without `#` (`FF8800`). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     name?: string | null,
>     description?: string | null,
>     color?: string | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

## Reports

### delete

`reports.delete`

Delete a report permanently.

**Risk:** `destructive`

```ts theme={null}
await corsair.gtmetrix.api.reports.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `reportId` | `string` | Yes | Report id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### get

`reports.get`

Get a report: grade, scores, Core Web Vitals, timings, page size, and links to its files.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.reports.get({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `reportId` | `string` | Yes | Report id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     test?: string | null,
>     source?: string | null,
>     page_tags?: string[] | null,
>     browser?: string | null,
>     location?: string | null,
>     created?: number | null,
>     expires?: number | null,
>     gtmetrix_grade?: string | null,
>     gtmetrix_score?: number | null,
>     performance_score?: number | null,
>     structure_score?: number | null,
>     pagespeed_score?: number | null,
>     yslow_score?: number | null,
>     html_bytes?: number | null,
>     page_bytes?: number | null,
>     page_requests?: number | null,
>     redirect_duration?: number | null,
>     connect_duration?: number | null,
>     backend_duration?: number | null,
>     time_to_first_byte?: number | null,
>     first_paint_time?: number | null,
>     first_contentful_paint?: number | null,
>     dom_interactive_time?: number | null,
>     dom_content_loaded_time?: number | null,
>     dom_content_loaded_duration?: number | null,
>     onload_time?: number | null,
>     onload_duration?: number | null,
>     fully_loaded_time?: number | null,
>     rum_speed_index?: number | null,
>     speed_index?: number | null,
>     largest_contentful_paint?: number | null,
>     time_to_interactive?: number | null,
>     total_blocking_time?: number | null,
>     cumulative_layout_shift?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### resource

`reports.resource`

Download a report file: screenshot, HAR, filmstrip, video, Lighthouse JSON, resource summary or PDF. report.pdf spends 0.2 credits (0.3 full). analysis-options includes the test's cookies and HTTP auth.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.reports.resource({ reportId: '<report id>', resource: 'net.har' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `reportId` | `string` | Yes | Report id from GTmetrix. |
| `resource` | `screenshot.jpg \| filmstrip.json \| filmstrip-frame.jpg \| net.har \| analysis-options \| video.mp4 \| optimized-images.tar \| report.pdf \| lighthouse.json \| pagespeed.json \| pagespeed-files.tar \| yslow.json \| resource-summary.json \| resource-summary` | Yes | The report file. `report.pdf` costs 0.2 credits (0.3 with `full`). |
| `full` | `boolean` | No | With report.pdf: the full PDF (0.3 credits). |
| `base64` | `boolean` | No | With filmstrip.json: include each frame as base64 JPEG. |
| `frameId` | `string` | No | With filmstrip-frame.jpg: the frame id from filmstrip.json. |

report.pdf spends credits. filmstrip-frame.jpg needs `frameId` from
filmstrip.json. optimized-images.tar and pagespeed-files.tar expire 24
hours after the report.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `contentBase64` | `string` | No | The file, base64-encoded. Missing when the file came back as text or contentOmitted is set. |
| `text` | `string` | No | The file as text, in place of contentBase64, when it is a text file (CSV, JSON, Markdown, XML and the like) in UTF-8. |
| `contentType` | `string` | Yes | Media type of the file, for example application/pdf. |
| `byteLength` | `number` | Yes | Size of the file in bytes. |
| `filename` | `string` | No | The file name, when known. |
| `contentOmitted` | `not_requested \| over_limit` | No | Set when the content was left out: the caller did not ask for it, or the file was over the limit. |
| `fileId` | `string` | No | Where the host saved the file. Over the limit it comes in place of the content; a host that keeps every file sets it beside the content too. On Corsair it is a Files id (fil\_…): pass it to another app wherever that app takes a file URL, or read a text file or PDF with files.read\_text. |

***

### retest

`reports.retest`

Run a new test with a report's settings. Spends API credits like tests.start.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.reports.retest({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `reportId` | `string` | Yes | Report id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     report?: string | null,
>     source?: string | null,
>     location?: string | null,
>     browser?: string | null,
>     state?: string | null,
>     error?: string | null,
>     created?: number | null,
>     started?: number | null,
>     finished?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

## Simulated Devices

### get

`simulatedDevices.get`

Get one simulated device.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.simulatedDevices.get({ deviceId: 'iphone_15' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `deviceId` | `string` | Yes | Simulated device id from GTmetrix. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     category?: string | null,
>     name?: string | null,
>     manufacturer?: string | null,
>     user_agent?: string | null,
>     height?: number | null,
>     width?: number | null,
>     dppx?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### list

`simulatedDevices.list`

List the phones and tablets a test can simulate (viewport, pixel ratio, user agent).

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.simulatedDevices.list({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     category?: string | null,
>     name?: string | null,
>     manufacturer?: string | null,
>     user_agent?: string | null,
>     height?: number | null,
>     width?: number | null,
>     dppx?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

## Status

### get

`status.get`

Get the account's API credit balance, next refill and plan access. The API key GTmetrix returns as the record id is removed.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.status.get({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   attributes?: {
>     api_credits?: number | null,
>     api_refill?: number | null,
>     api_refill_amount?: number | null,
>     account_type?: string | null,
>     account_pro_analysis_options_access?: boolean | null,
>     account_pro_locations_access?: boolean | null,
>     account_whitelabel_pdf_access?: boolean | null
>   } | null
> }
> ```

***

## Tests

### get

`tests.get`

Poll a test. While it runs this returns its state; once complete GTmetrix redirects to the report, which is returned instead.

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.tests.get({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `testId` | `string` | Yes | Test id from GTmetrix. |

While the test runs this returns `{ data: { type: "test", attributes: { state } } }`.
Once complete GTmetrix answers 303 to the report and the report is returned.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     report?: string | null,
>     source?: string | null,
>     location?: string | null,
>     browser?: string | null,
>     state?: string | null,
>     error?: string | null,
>     created?: number | null,
>     started?: number | null,
>     finished?: number | null
>   } | null,
>   links?: Record<string, any> | null
> } | {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     test?: string | null,
>     source?: string | null,
>     page_tags?: string[] | null,
>     browser?: string | null,
>     location?: string | null,
>     created?: number | null,
>     expires?: number | null,
>     gtmetrix_grade?: string | null,
>     gtmetrix_score?: number | null,
>     performance_score?: number | null,
>     structure_score?: number | null,
>     pagespeed_score?: number | null,
>     yslow_score?: number | null,
>     html_bytes?: number | null,
>     page_bytes?: number | null,
>     page_requests?: number | null,
>     redirect_duration?: number | null,
>     connect_duration?: number | null,
>     backend_duration?: number | null,
>     time_to_first_byte?: number | null,
>     first_paint_time?: number | null,
>     first_contentful_paint?: number | null,
>     dom_interactive_time?: number | null,
>     dom_content_loaded_time?: number | null,
>     dom_content_loaded_duration?: number | null,
>     onload_time?: number | null,
>     onload_duration?: number | null,
>     fully_loaded_time?: number | null,
>     rum_speed_index?: number | null,
>     speed_index?: number | null,
>     largest_contentful_paint?: number | null,
>     time_to_interactive?: number | null,
>     total_blocking_time?: number | null,
>     cumulative_layout_shift?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***

### list

`tests.list`

List tests from the last 24 hours, with paging, sorting and filters (state, source, created, browser, location).

**Risk:** `read`

```ts theme={null}
await corsair.gtmetrix.api.tests.list({
	pageSize: 10,
	filter: { state: 'completed' },
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `page` | `number` | No | Page number (1-based). |
| `pageSize` | `number` | No | Results per page, up to 500. |
| `sort` | `string` | No | Comma-separated attributes to sort by; prefix `-` for descending (`-created`). |
| `filter` | `Record<string, string \| number \| (string \| number)[]>` | No | Filters by attribute, with an optional operator suffix: `{ "state": "completed" }`, `{ "created:gt": 1617680457 }`, `{ ":bool": "OR" }`. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `links` | `Record<string, any> \| null` | No | — |
| `meta` | `object \| null` | No | — |
| `next_page` | `number \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     report?: string | null,
>     source?: string | null,
>     location?: string | null,
>     browser?: string | null,
>     state?: string | null,
>     error?: string | null,
>     created?: number | null,
>     started?: number | null,
>     finished?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   curr_page?: number | string | null
> } | null
> ```

***

### start

`tests.start`

Start a page test. Spends API credits: 1 for Lighthouse, 0.7 legacy, 1.1 both, 0.6 metrics only, plus video and retention add-ons.

**Risk:** `write`

```ts theme={null}
await corsair.gtmetrix.api.tests.start({
	url: 'https://example.com/',
	report: 'lighthouse',
	location: '24',
	browser: '3',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | URL of the page to test. |
| `location` | `string` | No | Location id from locations.list (default: account setting). |
| `browser` | `string` | No | Browser id from browsers.list (default: account setting). |
| `report` | `lighthouse \| legacy \| lighthouse,legacy \| none` | No | Report type. Costs: lighthouse 1 credit, legacy 0.7, both 1.1, none (metrics only) 0.6. |
| `retention` | `1 \| 6 \| 12 \| 24` | No | Months to keep the report: 1 (included), 6 (+0.4), 12 (+0.9), 24 (+1.8 credits). |
| `httpauth_username` | `string` | No | — |
| `httpauth_password` | `string` | No | — |
| `adblock` | `0 \| 1` | No | — |
| `cookies` | `string[]` | No | — |
| `video` | `0 \| 1` | No | 1 records a video (+0.9 credits). |
| `stop_onload` | `0 \| 1` | No | — |
| `throttle` | `string` | No | Connection throttle as `down/up/latency` (`5000/1000/30`). |
| `allow_url` | `string[]` | No | — |
| `block_url` | `string[]` | No | — |
| `dns` | `string[]` | No | `host:ip` overrides. |
| `simulate_device` | `string` | No | Simulated device id from simulatedDevices.list. |
| `user_agent` | `string` | No | — |
| `browser_width` | `number` | No | — |
| `browser_height` | `number` | No | — |
| `browser_dppx` | `number` | No | — |
| `browser_rotate` | `0 \| 1` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | — |
| `meta` | `object \| null` | No | — |
| `links` | `Record<string, any> \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   type?: string | null,
>   id?: string | null,
>   attributes?: {
>     url?: string | null,
>     page?: string | null,
>     report?: string | null,
>     source?: string | null,
>     location?: string | null,
>     browser?: string | null,
>     state?: string | null,
>     error?: string | null,
>     created?: number | null,
>     started?: number | null,
>     finished?: number | null
>   } | null,
>   links?: Record<string, any> | null
> }
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   credits_left?: number | null,
>   credits_used?: number | null
> } | null
> ```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.