PHP, Node.js and build tools API
List, install, remove and set the default PHP and Node.js versions, edit php.ini and extensions, manage ionCube, and install the build tools through the OSS Panel API.
The runtimes your applications run on are managed server-wide: PHP versions (with
their php.ini, extensions and the ionCube Loader), Node.js versions (with npm),
and the compiler toolchain npm falls back to for native modules. Installs take
minutes, so the install endpoints answer 202 and run in the background; you
poll the matching GET endpoint for progress.
All paths are relative to https://<your-panel-host>/api. Read
Authentication first. The examples use:
PANEL=https://panel.example.com
TOKEN='1|xcMq8K3vZ2pL…'Permissions
| Key | Title in Roles | Used for |
|---|---|---|
php | PHP | Everything under /php. |
node | Node.js | Everything under /node and /build-tools. Build tools have no permission of their own. |
Reading needs view; every endpoint marked manage needs manage, which
implies view. None of these routes has a limit of its own. They draw on the
shared budget (see Rate limits),
except GET /php, GET /node and GET /build-tools, which are polled while an
install runs and sit outside that budget.
The routes only exist where they make sense:
/php/…answers409on a server that hosts containers, because it serves no PHP applications (This server hosts containers, so it serves no PHP applications…)./node/…answers409on a server that runs no applications on the host itself.
Endpoint index
| Method | Path | Permission | Purpose |
|---|---|---|---|
GET | /php | php | PHP versions, default, install progress. |
PUT | /php/default | php manage | Set the default version. |
POST | /php/versions | php manage | Install a version. |
DELETE | /php/versions/{version} | php manage | Remove a version, or clear a failed install. |
GET | /php/versions/{version}/ini | php | Read the whole php.ini. |
PUT | /php/versions/{version}/ini | php manage | Replace the whole php.ini. |
GET | /php/versions/{version}/settings | php | Read the common settings. |
PUT | /php/versions/{version}/settings | php manage | Change the common settings. |
GET | /php/versions/{version}/extensions | php | List extensions. |
PUT | /php/versions/{version}/extensions/{extension} | php manage | Turn an extension on or off. |
GET | /php/versions/{version}/ioncube | php | ionCube Loader status. |
POST | /php/versions/{version}/ioncube | php manage | Install the ionCube Loader. |
DELETE | /php/versions/{version}/ioncube | php manage | Remove the ionCube Loader. |
GET | /node | node | Node.js versions, default, npm. |
PUT | /node/default | node manage | Set the default version. |
POST | /node/versions | node manage | Install a version. |
DELETE | /node/versions/{version} | node manage | Remove a version, or clear a failed install. |
POST | /node/versions/{version}/npm | node manage | Update npm for one version. |
GET | /build-tools | node | Build tools status. |
POST | /build-tools/install | node manage | Install the build tools. |
PHP
A version is written major.minor, for example 8.3. {version} in a path is
that string.
GET /php
curl "$PANEL/api/php" \
-H "Authorization: Bearer $TOKEN" -H 'Accept: application/json'{
"php": {
"default": "8.3",
"default_full_version": "8.3.14",
"panel_version": "8.3",
"versions": [
{
"version": "8.3",
"status": "ready",
"full_version": "8.3.14",
"in_use_by": 2,
"sites": ["shop", "blog"],
"sites_truncated": false,
"service": "php8.3-fpm",
"ini_path": "/etc/php/8.3/fpm/php.ini",
"missing_packages": []
}
],
"installable": [{"version": "8.4"}],
"lifecycle_available": true
}
}panel_version is the version the panel itself runs on: it cannot be removed.
in_use_by counts the applications pinned to a version and sites names them.
installable lists versions you can still install. lifecycle (support
dates) is added to each entry when available. While a version installs or is
removed, its entry carries the progress status.
PUT /php/default
Body default (required): a version string such as 8.3. The version must be
installed, otherwise 422. Returns {"php": { … }, "cronjobs_on_default_php": [ … ]}:
the overview and the cron jobs that follow the server default and so changed
version with it.
POST /php/versions
Body version (required): major.minor, and a version the server's package
sources offer. A version below the lowest the panel offers, or one that is not
available, is refused with 422.
Answers 202 with {"message": "…"} and installs in the background. If the
version is already installed and complete you get 200 with a message instead.
DELETE /php/versions/{version}
Answers 202 with {"message": "…"} and removes it in the background. For a
version whose install failed, it only clears the failed entry and answers 204.
It is refused with 422 when the version:
- is the one the panel runs on,
- is pinned by applications (the message names them),
- is named by cron jobs (the message names them), or
- is the default.
An unknown version answers 404.
GET /php/versions/{version}/ini and PUT …/ini
GET returns {"php_ini": {"version", "path", "contents"}}.
PUT replaces the whole file and returns the same shape.
| Field | Rules |
|---|---|
contents | Required, string, up to 262144 bytes (256 KiB). |
acknowledged | Required and accepted (true): you confirm a raw edit. |
safety_copy | Optional boolean, default true: keep a copy of the previous file. |
The panel tests the new file. If PHP rejects it, the previous one is restored, nothing is reloaded and the answer is an error (PHP rejected that configuration, so the previous one was restored.). Extension lines may only load from PHP's own extension folder.
GET /php/versions/{version}/settings and PUT …/settings
The common directives as fields. GET returns {"version", "settings": { … }},
and PUT changes only the lines you send and returns the same shape.
| Field | Rules |
|---|---|
memory_limit | Size: -1, or a number with an optional K, M or G, up to 12 characters. |
upload_max_filesize | Size, as above. |
post_max_size | Size, as above. Must not be below upload_max_filesize, unless it is -1. |
max_execution_time | Integer 0 to 3600 seconds. |
max_input_time | Integer -1 to 3600 seconds. |
max_input_vars | Integer 100 to 100000. |
safety_copy | Optional boolean, default true. |
GET /php/versions/{version}/extensions
Returns:
{
"extensions": [
{
"name": "gd",
"package": "php8.3-gd",
"modules": ["gd"],
"installed": true,
"enabled": true,
"builtin": false,
"summary": null,
"sapis": []
}
],
"toggle_supported": true,
"panel_required": []
}builtin extensions are compiled into PHP and cannot be turned off.
toggle_supported is false on stacks that cannot enable or disable extensions
(the request is then refused). panel_required names what the panel itself
needs when {version} is the panel's own version. An unknown or uninstalled
version answers 404.
PUT /php/versions/{version}/extensions/{extension}
Body enabled (required, boolean).
- Turning an extension on that is not installed starts an install and answers
202with{"message": "…"}. - Otherwise it answers
200with{"extension": { … }}. - A built-in extension, or one the panel needs on its own PHP version, cannot be
turned off:
422.
ionCube Loader
GET /php/versions/{version}/ioncube returns {"ioncube": { … }} with the
Loader's state plus status (idle, installing, ready or failed),
reason, message and reference.
POST installs it and answers 202 with {"ioncube": { … }}. DELETE removes
it and answers 200 with {"ioncube": { … }}. Both take an optional
safety_copy boolean (default true) for the PHP configuration files they
touch. POST is refused with 422 when ionCube publishes no Loader for that
PHP version, or when the Loader was installed outside the panel (by a system
package, or by ServerAvatar v7).
Node.js
A version is written major.minor.patch, for example 22.11.0.
GET /node
Returns {"node": { … }} with manager, default, versions, system,
installable and installable_error. Each entry of versions has version,
npm_version, npm_latest, npm_update_available, in_use_by, sites and
sites_truncated, and carries its install status while it installs.
PUT /node/default
Body default (required): major.minor.patch. It must be installed (422
otherwise). Returns {"node": { … }}.
POST /node/versions
Body version (required): major.minor.patch, and a release that exists
(Node.js <version> does not exist. Choose a version from the list. is a 422).
Answers 202 with {"message": "…"}. Already installed: 200. Already being
installed or removed: 409 with reason: "install_in_progress".
DELETE /node/versions/{version}
Answers 204 when the version is removed, or when it was a failed install and
the failed entry is cleared. Refused with 422 when applications use the
version (the message names them), when it is the default, or when it is the one
the panel runs on. Unknown: 404.
POST /node/versions/{version}/npm
No body. Updates npm for that Node version to the newest release it can run.
Returns {"message", "npm_version", "npm_latest", "npm_update_available"}. If
the npm release list cannot be reached the answer is 422.
Build tools
GET /build-tools
{
"build_tools": {
"installed": false,
"missing": ["build-essential", "python3"],
"install_status": null,
"install_reason": null,
"install_message": null
}
}POST /build-tools/install
No body. Answers 202 with {"message": "…"}. 422 when the tools are already
installed, 409 when an install is already running.
Common errors
| Status | Message or cause |
|---|---|
403 | Your role does not include management for PHP. (or Node.js). |
404 | Unknown or uninstalled version, extension or failed install. |
409 | The server runs no PHP or host applications; an install of that Node.js version or of the build tools is already running. |
422 | Validation ({"message", "errors": {"field": ["…"]}}); a version that is in use, the default, or the panel's own; a built-in extension; an invalid php.ini. |
429 | Over a limit; wait for Retry-After. |
500 | {"message", "reference"}: find the reference in the error log. The change was made, but PHP … could not be reloaded means the file is saved but not active yet. |
Related
- PHP and Node.js: the same features in the panel
- Applications API:
PUT /applications/{application}/node-versionand the per-application PHP settings - Application features API: per-application PHP
Firewall and Fail2ban API
Read and change the server firewall rules, switch the firewall on or off, and manage Fail2ban settings, the ignore list and bans through the OSS Panel API.
Server operations API
Read server metrics and processes, control services, read and clear logs, list background operations, manage cron jobs and the disk cleaner, and read the server activity log through the OSS Panel API.