## POST /api/v2/shared-hosting/{accountId}/page-cache/actions/purge

**Purge website page cache**

Empty the stored page cache of one website on a cPanel-based shared-hosting account: the generic fix when visitors get a stale or broken copy of a page while the logged-in owner sees the real site. Get `{accountId}` from `GET /api/v2/shared-hosting` `data[].id`. Removes the entries of `wp-content/cache/` under the site's document root (WP-Optimize, WP Rocket, WP Super Cache, Cache Enabler, Autoptimize, LiteSpeed Cache combos, W3 Total Cache) and of the account's `lscache/` directory (LiteSpeed's server cache), so a cached copy of the same page is gone in one call. The directories themselves and the `advanced-cache.php` drop-in stay; the plugins recreate what they need. `domain` chooses which of the account's sites; it defaults to the main domain. Paths are derived from the control panel's document root and home directory only. This is a synchronous action: 200 reports what was purged. A site with nothing to purge still returns 200 with `entries: 0`. Accounts on a control panel without file-API access return 409 `account_not_eligible_cpanel`.

### Related Endpoints

- `GET /api/v2/shared-hosting/{accountId}`: Get shared-hosting account
- `PATCH /api/v2/shared-hosting/{accountId}`: Rename shared-hosting account
- `GET /api/v2/shared-hosting/{accountId}/backups`: List hosting backups

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scopes: `write:hosting`, `console:services`
- `Content-Type`: application/json

### Parameters

- `accountId` (path, string, required): Public shared-hosting account ID from `GET /api/v2/shared-hosting` `data[].id`. Do not invent this value; use the exact ID returned by the referenced API response. Example: `acct_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `domain` (string, optional): Full hostname of one of the account's websites, such as `shop.example.com`. Defaults to the account's main domain. Example: `example.com`

### Request Examples

#### Purge the main site

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/page-cache/actions/purge" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json"
```

#### Purge a specific site on the account

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/page-cache/actions/purge" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "shop.example.com"
  }'
```

```json
{
  "domain": "shop.example.com"
}
```

### Response Schema

- `domain` (string, required) Example: `example.com`
- `purged` (array<object>, required)
- `purged[].path` (string, required): Directory relative to the account's home directory. Example: `public_html/wp-content/cache`
- `purged[].entries` (integer, required) Example: `148`
- `skipped` (array<object>, required)
- `skipped[].path` (string, required) Example: `lscache`
- `skipped[].reason` (string, required) Example: `not_present`
  Allowed values: not_present, delete_failed

### Responses

#### 200 - Purge finished.
```json
{
  "domain": "example.com",
  "purged": [
    {
      "path": "public_html/wp-content/cache",
      "entries": 148
    }
  ],
  "skipped": [
    {
      "path": "lscache",
      "reason": "not_present"
    }
  ]
}
```

#### 400 - `domain` is not a full hostname.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "`domain` must be a full hostname such as \"example.com\".",
  "code": "invalid_request",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/page-cache/actions/purge",
  "errors": [
    {
      "pointer": "/body/domain",
      "detail": "`domain` must be a full hostname such as \"example.com\".",
      "code": "invalid_request"
    }
  ]
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - Forbidden. The caller lacks a required scope or does not own the resource.
```json
{
  "type": "https://developer.hostup.se/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "The caller lacks a required scope or does not own the resource.",
  "code": "forbidden",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 409 - The account's control panel does not support this action through the API.
```json
{
  "type": "https://developer.hostup.se/errors/account_not_eligible_cpanel",
  "title": "Action not available on this platform",
  "status": 409,
  "detail": "Page-cache purge through the API is unavailable on the account's current platform. Use the account's own control panel for this instead.",
  "code": "account_not_eligible_cpanel",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/page-cache/actions/purge"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Too many requests. Retry after the limit resets.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 502 - The control panel's file API did not respond.
```json
{
  "type": "https://developer.hostup.se/errors/upstream_failed",
  "title": "Upstream request failed",
  "status": 502,
  "detail": "The website's page cache could not be purged right now.",
  "code": "upstream_failed",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/page-cache/actions/purge"
}
```
