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

**Purge a website's page cache**

Empty a website's stored page cache. Use it when visitors get an old or broken copy of a page while you see the real site when logged in. The call deletes the contents of `wp-content/cache/` in the website's folder. That is where WordPress cache plugins such as WP-Optimize, WP Rocket, WP Super Cache and W3 Total Cache keep their pages. It also empties the account's `lscache/` folder, the web server's page cache for every website on the account. The folders themselves stay, as do any `.htaccess`, `index.php` and `index.html` in them. The cache fills again on the next visits. The response lists what was emptied and what was skipped. The account must be active and on cPanel.

### Related Endpoints

- `GET /api/v2/shared-hosting/{accountId}`: Get a web hosting account
- `PATCH /api/v2/shared-hosting/{accountId}`: Rename a web hosting account
- `GET /api/v2/shared-hosting/{accountId}/php`: Get PHP versions per website

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scopes: `write:hosting`, `console:services`
- `Content-Type`: application/json

### Parameters

- `accountId` (path, string, required): The web hosting account ID (`acct_…`). Example: `acct_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `domain` (string, optional): The website, as a full host name on the account such as `shop.example.com`. Default: the account's main domain. Example: `example.com`

### Request Examples

#### The account's main website

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

#### Another website on the account

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

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

### Response Schema

- `domain` (string, required): The website whose cache was emptied. Example: `example.com`
- `purged` (array<object>, required): Cache folders that were emptied.
- `purged[].path` (string, required): The folder, relative to the account's home folder. Example: `public_html/wp-content/cache`
- `purged[].entries` (integer, required): Entries deleted. `0` means the folder was already empty. Example: `148`
- `skipped` (array<object>, required): Folders or entries that were not emptied.
- `skipped[].path` (string, required): The folder or entry, relative to the account's home folder. Example: `lscache`
- `skipped[].reason` (string, required): `not_present`: the folder does not exist. `delete_failed`: the entry could not be deleted. Example: `not_present`
  Allowed values: not_present, delete_failed

### Responses

#### 200 - What was emptied and what was skipped.
```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 host name (`invalid_request`).
```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 - The key lacks a scope or the account is not active. `domain_not_owned`: the domain is not on this account.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Validation failed",
  "status": 400,
  "detail": "The request body failed validation.",
  "code": "invalid_request",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z",
  "errors": [
    {
      "pointer": "/name",
      "detail": "`name` is required.",
      "code": "invalid_request"
    }
  ]
}
```

#### 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 is not on cPanel (`account_not_eligible_cpanel`).
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Validation failed",
  "status": 400,
  "detail": "The request body failed validation.",
  "code": "invalid_request",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z",
  "errors": [
    {
      "pointer": "/name",
      "detail": "`name` is required.",
      "code": "invalid_request"
    }
  ]
}
```

#### 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": "Rate limit exceeded. Please try again later.",
  "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 cache folder could not be read or emptied right now (`upstream_failed`). Try again later.
```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"
}
```
