---
title: Toggle OPCache for PHP Version
description: "Enable or disable OPCache for a PHP version. Synchronous over SSH. Requires the write:servers scope and the server:manage-php permission."
url: "https://betterdocs.shahrear.msf.bd/index.php/docs/hell0-boys-docs/hell0-boys/servers/toggle-opcache-for-php-version/"
updated: "2026-08-20"
category: hell0 boys / Servers
---

# Toggle OPCache for PHP Version

POST`/servers/{uuid}/php-versions/{version}/opcache`

## Code Samples

```curl

                curl --request POST \
  --url 'https://app.xcloud.host/api/v1/servers/{uuid}/php-versions/{version}/opcache' \
  --header 'Authorization: Bearer YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "enabled": true
}'

                const response = await fetch('https://app.xcloud.host/api/v1/servers/{uuid}/php-versions/{version}/opcache', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "enabled": true
})
});

const data = await response.json();
console.log(data);

                import requests

headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
}

payload = {
    "enabled": true
}

response = requests.post("https://app.xcloud.host/api/v1/servers/{uuid}/php-versions/{version}/opcache", headers=headers, json=payload)

print(response.json())

                <?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://app.xcloud.host/api/v1/servers/{uuid}/php-versions/{version}/opcache',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
  'Authorization: Bearer YOUR_TOKEN',
  'Content-Type: application/json'
  ],
  CURLOPT_POSTFIELDS => '{
    "enabled": true
}',
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;

                using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://app.xcloud.host/api/v1/servers/{uuid}/php-versions/{version}/opcache");
request.Headers.Add("Authorization", "Bearer YOUR_TOKEN");
request.Content = new StringContent(@"{
    ""enabled"": true
}", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

                import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://app.xcloud.host/api/v1/servers/{uuid}/php-versions/{version}/opcache"))
    .header("Authorization", "Bearer YOUR_TOKEN")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
{
    "enabled": true
}
"""))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

## Response

```json

                {
    "success": true,
    "message": "Operation completed successfully.",
    "data": {
        "version": "string",
        "opcache_enabled": true
    }
}

                {
    "success": false,
    "message": "Unauthenticated.",
    "data": null
}

                {
    "success": false,
    "message": "This action is unauthorized. Your token is missing the required scope.",
    "data": null
}

                {
    "success": false,
    "message": "Not found.",
    "data": null
}

                {
    "success": false,
    "message": "The given data was invalid.",
    "data": null,
    "errors": {
        "domain": [
            "The domain field is required when mode is live."
        ]
    }
}

                {
    "success": false,
    "message": "An error occurred.",
    "data": null
}
```

Enable or disable OPCache for a PHP version. Synchronous over SSH. Requires the `write:servers` scope and the `Server:manage-php` permission.

## Path Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `uuid` | string (uuid) | **Required** | UUID of the [Server](https://betterdocs.shahrear.msf.bd/encyclopedia/server/) |
| `version` | string | **Required** |  |

## Request Body

Content type: `application/json` — **required**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean | **Required** |  |

```json

                {
    "enabled": true
}
```

## Responses

### 200 — OPCache state updated

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |
| `data` | object | Optional |  |
| `data.version` | string | Optional |  |
| `data.opcache_enabled` | boolean | Optional |  |

```json

                {
    "success": true,
    "message": "Operation completed successfully.",
    "data": {
        "version": "string",
        "opcache_enabled": true
    }
}
```

### 401 — Missing or invalid authentication token

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |

```json

                {
    "success": false,
    "message": "Unauthenticated.",
    "data": null
}
```

### 403 — Token lacks the required scope

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |

```json

                {
    "success": false,
    "message": "This action is unauthorized. Your token is missing the required scope.",
    "data": null
}
```

### 404 — Resource not found or not accessible to your [Team](https://betterdocs.shahrear.msf.bd/encyclopedia/team/)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |

```json

                {
    "success": false,
    "message": "Not found.",
    "data": null
}
```

### 422 — Request validation failed

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |
| `errors` | object | Optional |  |

```json

                {
    "success": false,
    "message": "The given data was invalid.",
    "data": null,
    "errors": {
        "domain": [
            "The domain field is required when mode is live."
        ]
    }
}
```

### 502 — Failed to update OPCache state

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |

```json

                {
    "success": false,
    "message": "An error occurred.",
    "data": null
}
```
