## POST /api/v2/shared-hosting/{accountId}/wordpress/{siteId}/actions/debug-mode

**Turn WordPress debug mode on or off**

Turns WordPress debug mode (`WP_DEBUG` in the site's `wp-config.php`) on or off for one site. The change is made before the response returns. Nothing else on the site changes.

With debug mode on, warnings and notices from WordPress, plugins and themes can show on the site's pages, also to visitors. Turn it on to find the cause of an error and turn it off again afterwards. With debug mode off, those lines are no longer shown.

The web hosting account must be active and on cPanel. A change that could not be made returns 502 `upstream_failed`.

### Related Endpoints

- `POST /api/v2/shared-hosting/{accountId}/wordpress/{siteId}/actions/sso`: Get a WordPress admin login link
- `POST /api/v2/shared-hosting/{accountId}/wordpress/{siteId}/actions/clone`: Clone a WordPress site
- `POST /api/v2/shared-hosting/{accountId}/wordpress/{siteId}/actions/staging`: Create a WordPress staging copy

### 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`
- `siteId` (path, string, required): The WordPress site ID (`wp_…`). Example: `wp_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `enabled` (boolean, required): `true` turns debug mode on. `false` turns it off.

### Request Example

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/wordpress/wp_01hxa3b4c5d6e7f8g9h0j1k2m3/actions/debug-mode" \
  -H "Authorization: Bearer $HOSTUP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true
  }'
```

```json
{
  "enabled": true
}
```

### Response Schema

- `id` (string, required): The WordPress site ID (`wp_…`). Example: `wp_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `debugMode` (boolean, required): The state after the call: `true` when debug mode is on. Example: `false`

### Responses

#### 200 - Debug mode was changed.
```json
{
  "id": "wp_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "debugMode": false
}
```

#### 400 - `siteId` is invalid or `enabled` is not `true` or `false` (`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; `code` is `wp_installation_not_found`.
```json
{
  "type": "https://developer.hostup.se/errors/wp_installation_not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "wp_installation_not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 409 - `account_not_eligible_cpanel`: the account is not on 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 - Debug mode could not be changed right now (`upstream_failed`).
```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"
    }
  ]
}
```
