Docs cipi.yml Web panel API MCP Guides Compare GitHub Telegram channel
  1. Docs
  2. API & integrations
  3. REST API

REST API

Install the API, create tokens and call every endpoint.

API & integrations

cipi api <domain> adds an optional REST API and MCP server to a Cipi server. It's what the web panel, cipi-cli, the PHP SDK, WHMCS and your AI assistant talk to. It's a separate Laravel app (cipi/api, MIT) that runs as www-data and calls an allowlist of cipi commands through sudo: credentials never leave Cipi, and destructive host operations stay on the CLI.

Install the API and create a token
$ cipi api api.example.com
$ cipi api token create --name=ci --abilities=apps-view,deploy-manage
$ curl -s -H "Authorization: Bearer $TOKEN" https://api.example.com/api/apps
It exposesWhere
REST API for apps, deploys, domains, SSL, databases, backups, Node, search, cipi.yml, server status/api/*
MCP server for AI assistants/mcp (Streamable HTTP)
Interactive reference (Swagger UI, OpenAPI)/docs
  • Clientpanel, cipi-cli, SDK, CI, MCP
  • HTTPS + Sanctum tokenabilities, IP allowlist
  • cipi/apisync reads, async jobs (SQLite queue)
  • sudo allowlist/etc/sudoers.d/cipi-api
  • cipi CLIthe same code path as SSH

This is server-level automation. The per-app Cipi Agent (cipi/agent) is a different package.

A domain of its own#

The API has its own vhost and certificate, so it needs a hostname only it uses. Point an A/AAAA record at the server first: the command checks DNS and stops with the record to create (--skip-dns-check behind a NAT or proxy it can't see through; the Cloudflare proxy counts as pointing here).

WhatExampleSet up with
Your appexample.com, www.example.comcipi app create, cipi alias add
API + MCPapi.example.comcipi api api.example.com
Web panelpanel.example.comcipi gui panel.example.com

All three can share a server and a registered domain; each hostname belongs to one of them. Cipi refuses any overlap, in both directions (cipi app create, alias add, app clone, sync import and cipi.yml aliases won't take the API's or the panel's hostname). cipi api status warns if an old install shares a hostname with an app: fix it with cipi api move.

Commands#

bash
cipi api api.example.com          # DNS check, install, certificate, first token
cipi api ssl                      # (re)issue the certificate
cipi api status                   # versions, queue worker, pending jobs, FPM pool
cipi api token list
cipi api token create --name=panel --full-access
cipi api token create --name=ci --abilities=apps-view,deploy-manage --expires=2027-06-30
cipi api token revoke <id>
cipi api update                   # soft update (also nightly at 04:30)
cipi api upgrade                  # full rebuild, rollback kept at /opt/cipi/api.old
cipi api fix-permissions          # storage/database ownership back to www-data

Install flags: --no-ssl, --no-token, --skip-dns-check.

Change domain: cipi api move#

bash
cipi api move api.newdomain.com           # move and issue the certificate
cipi api move api.newdomain.com --no-ssl  # certificate later with cipi api ssl

Tokens, job history and the IP allowlist stay. The vhost is rewritten (and restored if nginx -t fails), /etc/cipi/api.json and APP_URL updated, cipi-queue restarted, the old certificate deleted (never one still used by an app) and a new one issued. Then update the URL in every client: panel Connections, cipi-cli profile, SDK config, MCP clients. Running cipi api <other-domain> on a configured server points you here instead of silently moving.

Remove: cipi api remove#

bash
cipi api remove           # alias: uninstall; --force skips the prompt

Removes the cipi-queue worker, vhost, FPM pool, crons, certificate, /opt/cipi/api (and backups), api.json, the IP allowlist and logs. All tokens die with it. Apps, databases and the panel are untouched; the sudoers allowlist stays because it's part of every Cipi install.

Tokens and abilities#

Authentication is Sanctum Bearer tokens. Each token gets a list of abilities, or --full-access (the wildcard *, which also covers abilities added in future releases). Give a CI job only what it needs: deploy-manage alone deploys.

AreaAbilities
Appsapps-view, apps-create, apps-edit, apps-delete, apps-suspend, apps-basicauth
App toolingapps-env, apps-auth (Composer auth.json), apps-artisan, apps-run, apps-deploy-config
Deploydeploy-manage (deploy, rollback, unlock, audit, status)
cipi.ymlyml-view, yml-manage
Domains and SSLaliases-view, aliases-create, aliases-delete, www-manage, ssl-manage
Routingredirects-view, redirects-manage, proxies-view, proxies-manage
Nodenode-view, node-manage (SSR restart), node-runtimes-manage
Databasesdbs-view, dbs-create, dbs-manage
Backupsbackups-view (never keys), backups-manage
Serverstatus-view, php-view, php-manage, ssh-view, ssh-manage, services-view, services-manage, smtp-view, smtp-manage, health-view, health-manage, ip-whitelist-view, ip-whitelist-manage
Read-only insightssearch-view, search-manage, packages-view, monitor-view, zt-view, disk-view
MCPmcp-access (covers every MCP tool)

php artisan cipi:token-abilities (or the cipi api token create checklist) shows the canonical list.

REST endpoints#

Every call needs Authorization: Bearer <token>. Reads are synchronous. Writes are async jobs: they answer 202 with a job_id; poll GET /api/jobs/{id} (with the ability the job was created under) for status, output and a structured result (credentials, backup path, webhook token).

Apps#

MethodPathAbility
GET/api/apps, /api/apps/{name}apps-view
POST/api/appsapps-create
PUT/api/apps/{name}apps-edit
DELETE/api/apps/{name}apps-delete
POST/api/apps/{name}/suspend, /unsuspendapps-suspend
POST/api/apps/{name}/fix-permissions, /webhook/recreateapps-edit
GET, POST/api/apps/{name}/basicauth, /enable, /disableapps-basicauth
GET, PUT/api/apps/{name}/envapps-env
GET POST PUT DELETE/api/apps/{name}/authapps-auth
POST/api/apps/{name}/artisanapps-artisan
GET, POST/api/run-commands, /api/apps/{name}/runapps-run
GET, PUT/api/apps/{name}/deploy-configapps-deploy-config
GET, PUT/api/apps/{name}/limitsapps-view / apps-edit
GET, PUT, DELETE/api/apps/{name}/health, POST …/health/checkhealth-view / health-manage
GET/api/apps/{name}/logs?type=&page=&per_page=apps-view

POST /api/apps takes domain, repository, branch, php, env, engine (mariadb/pgsql), octane, node_build, custom + docroot (repository optional for SFTP-only sites), or Node fields (node: spa|static|ssr, framework, node_version, build, start, output, health_path). The same rules as cipi app create apply. PUT forwards only fields that changed; a domain already used elsewhere answers 409. App objects return type (laravel, custom, node), env, suspended, basic_auth, octane, redirects, proxies and databases.

Deploy and cipi.yml#

MethodPathAbility
POST/api/apps/{name}/deploy, /deploy/rollback, /deploy/unlockdeploy-manage
GET/api/apps/{name}/deploy/status?tail=Ndeploy-manage
GET/api/apps/{name}/deploy/audit?days=90deploy-manage
GET/api/apps/{name}/deploy/history?limit=N, /api/deploys/lastapps-view or deploy-manage
GET/api/apps/{name}/ymlyml-view
POST/api/apps/{name}/yml/apply (job)yml-manage
POST/api/apps/{name}/yml/auto/enable, /disableyml-manage

deploy/status is safe to poll: running, queued, interrupted or idle, with trigger, branch, phase, elapsed time and optional log tail. deploy/audit returns the hash-chained ledger.

GET /api/apps/{name}/yml is cipi yml plan <app> --json: the file of the live release, env, auto, valid and errors, in_sync, warnings, changes (kind, token, summary), blockers and notes. See cipi.yml.

Domains, SSL and routing#

MethodPathAbility
GET, POST, DELETE/api/apps/{name}/aliases[/{alias}]aliases-*
GET, POST/api/apps/{name}/www, /add, /force-to-root, /force-from-root, /clearwww-manage
POST/api/apps/{name}/ssl (dns, account, wildcard, http), /ssl/forcessl-manage
GET, PUT, DELETE/api/ssl/dns[/{account}] (Cloudflare accounts; token never returned)ssl-manage
GET/api/apps/{name}/redirectsredirects-view
PUT, DELETE, POST/api/apps/{name}/redirect, /redirect/enable, /disable, /redirectsredirects-manage
GET, POST, DELETE/api/apps/{name}/proxiesproxies-view / proxies-manage

Redirects and proxies use the CLI's own validation, regenerate the vhost and revert if nginx -t fails. The loopback guard on proxies is never bypassed from the API.

Databases and backups#

MethodPathAbility
GET/api/dbs?engine=, /api/dbs/enginesdbs-view
POST/api/dbs (name, engine, app)dbs-create
POST/api/dbs/{name}/backup, /restore, /passworddbs-manage
POST, DELETE/api/dbs/{name}/linkdbs-manage
GET, POST, DELETE/api/dbs/uploads/limits, /api/dbs/uploads, /uploads/{id}/chunksdbs-manage
POST/api/dbs/engines/installdbs-manage
GET/api/backups, /api/backups/runsbackups-view
POST, PUT, DELETE/api/backups/run, /verify, /destinations/test, /profiles[/{name}], …/enable, …/disablebackups-manage

Restore takes a server file or an upload_id: dumps (.sql, .sql.gz, up to 2 GB by default) are uploaded in chunks and deleted when the job ends. Backup destinations are read-only over the API: S3 secret keys are added on the server with cipi backup destination add.

Server#

MethodPathAbility
GET/api/status (same JSON as cipi status)status-view
GET, POST/api/php, /api/php/installphp-view / php-manage
GET, POST, DELETE/api/ssh/keys[/{n}]ssh-view / ssh-manage
GET, POST/api/services, /services/{name}/restartservices-view / services-manage
GET, PUT, DELETE, POST/api/smtp, /smtp/enable, /disable, /testsmtp-view / smtp-manage
GET/api/healthhealth-view
GET, POST, PUT, DELETE/api/node, /node/install, /node/upgrade, /node/default, /node/{major}node-view / node-runtimes-manage
GET, POST/api/apps/{name}/node, /node/restart (blue/green)node-view / node-manage
GET, POST/api/search, /api/apps/{name}/search/enable, /disablesearch-view / search-manage
GET/api/disk, /api/disk/dbsdisk-view
GET/api/packages, /api/monitor, /api/ztpackages-view, monitor-view, zt-view
GET/api/jobs/{id}the job's ability

Kept off the API on purpose: removing PHP versions, switching default PHP or engine, dropping databases, installing Meilisearch or host packages, stack upgrades, monitor thresholds and every Zero Trust change. Installing software or destroying data is an operator decision taken at the CLI, so a compromised token can't do it.

Examples#

bash
export CIPI_API_URL=https://api.example.com CIPI_API_TOKEN=<token>
H="Authorization: Bearer $CIPI_API_TOKEN"

curl -sS "$CIPI_API_URL/api/apps" -H "$H" -H "Accept: application/json"

curl -sS -X POST "$CIPI_API_URL/api/apps" -H "$H" -H "Content-Type: application/json" \
    -d '{"domain":"shop.example.com","repository":"git@github.com:you/shop.git","branch":"main","octane":true,"engine":"mariadb"}'
{"job_id":"9f1c…","status":"pending"}

curl -sS -X POST "$CIPI_API_URL/api/apps/shop/deploy" -H "$H"
curl -sS "$CIPI_API_URL/api/jobs/9f1c…" -H "$H"      # poll until completed

curl -sS -X PUT "$CIPI_API_URL/api/apps/shop/env" -H "$H" -H "Content-Type: application/json" \
    -d '{"set":{"APP_DEBUG":"false"},"unset":["LEGACY_KEY"]}'

curl -sS -X POST "$CIPI_API_URL/api/apps/shop/artisan" -H "$H" -H "Content-Type: application/json" \
    -d '{"command":"cache:clear"}'

curl -sS -X POST "$CIPI_API_URL/api/apps/shop/proxies" -H "$H" -H "Content-Type: application/json" \
    -d '{"prefix":"/api/","upstream":"http://127.0.0.1:3000","strip_prefix":true}'

A database backup through the API is a real backup. For a dump people can share, use the anonymizer.

Host integration#

The API runs as www-data and calls cipi through /etc/sudoers.d/cipi-api, an explicit allowlist of subcommands with their exact argument shapes, checked with visudo -cf whenever a migration regenerates it. Vault and MariaDB credentials stay inside Cipi, never in PHP. Its FPM pool has its own open_basedir.

SymptomFix
HTTP 500 on /docs or /mcp after an updatecipi api fix-permissions, then cipi api status
sudo: a terminal is requiredcipi self-update regenerates the allowlist
Panel says backups aren't configuredCompare ls -l /etc/cipi/backup.json with sudo -u www-data sudo -n /usr/local/bin/cipi backup status --json

IP allowlist#

Restrict REST and MCP clients by source IP. /etc/cipi/api-ip-whitelist holds one IPv4/IPv6 address or CIDR per line; * or no file allows all. Rejected clients get 403 {"error":"IP not allowed","ip":"…"}.

bash
cipi api ip-whitelist show [--json]
cipi api ip-whitelist add 203.0.113.10
cipi api ip-whitelist set --ips=203.0.113.0/24,2001:db8::/32
cipi api ip-whitelist allow-all

Over REST (/api/ip-whitelist), PUT adds the caller's IP when tightening the list unless ensure_client_ip: false, so you can't lock yourself out by accident. The file is replaced atomically.

MCP server#

/mcp exposes the server to AI assistants: apps, deploys and audit, domains, SSL, redirects, proxies, Node, databases, search, limits, disk, cipi.yml, server management, logs, Artisan and job polling. A token with mcp-access covers every tool. Async tools return a job_id to poll with JobShow; log tools prepend a production warning and redact secrets.

bash
claude mcp add --transport http cipi-api https://api.example.com/mcp \
    --header "Authorization: Bearer <token>"

Setup for Cursor, VS Code, Claude Desktop and others is in MCP servers.

The cipi/api package#

cipi api <domain> provisions everything (/opt/cipi/api, Nginx, SSL, SQLite job queue, cipi-queue.service). For custom setups:

bash
composer require cipi/api
php artisan vendor:publish --tag=cipi-config
php artisan vendor:publish --tag=cipi-assets
php artisan migrate
php artisan cipi:seed-api-user
php artisan cipi:token-create

Requires PHP 8.3+ and Laravel 12.41+ or 13. The panel reads CIPI_APPS_JSON=/etc/cipi/apps.json (or the apps-public.json projection). Abilities live in config/cipi.php.