Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cipi Api Laravel Package

andreapollastri/cipi-api

An API layer for Cipi, the open-source Laravel server control panel. It exposes REST endpoints for managing servers, sites, databases, and deployments, so you can automate provisioning and administration from external apps and scripts.

View on GitHub
Deep Wiki
Context7

Getting Started

Install and configure

  • composer require the package, then publish its config so config/cipi.php exists — that file holds the API base URL, token and the ability list (yml-view, yml-manage are new in 1.35.0).
  • Point the package at your Cipi API host and supply a token. Tokens are minted on the server with cipi api token create, where you choose abilities.
  • Version your server first. Everything yml-related needs Cipi CLI ≥ 5.6.4. On the server: cipi self-update (runs migration 5.6.4). If you skip this, the four new routes answer 503 while every 1.34.0 route keeps working — so a green test suite elsewhere doesn't prove yml is available.
  • 5.6.4 also adds cipi yml plan --json / cipi yml auto status --json and the sudoers entries (/etc/sudoers.d/cipi-api) for cipi yml plan|apply|auto. If those sudoers lines are missing, the endpoints fail at the CLI layer, not in your app.

Where to look first

  1. config/cipi.php — confirm yml-view / yml-manage are in the ability map before writing any code.
  2. The OpenAPI document (info.version 1.35.0) — new cipi.yml tag, four paths, schemas YmlPlanResponse, YmlAutoResponse, JobResultAppYmlApply. Generate or refresh your client from it rather than hand-rolling payloads.
  3. CipiCliService::ALLOWED_COMMANDS — yml plan, yml apply, yml auto are whitelisted there; this is the list that gates anything tunnelled through the CLI service.

First use case (10 minutes)

Read the plan for an app you already deploy, read-only, no side effects:

$plan = Cipi::get("/api/apps/{$app}/yml");   // GET /api/apps/{name}/yml
// file, auto, valid{errors,warnings}, changes[], blockers[], notes, in_sync

Render changes (each has kind + summary) and blockers in a dashboard, and skip everything when in_sync is true. This is the single most useful call in the release: it tells you what a deploy would change and whether apply would refuse, before anything is queued.

Implementation Patterns

Plan → confirm → apply (the default workflow)

Treat GET /api/apps/{name}/yml as the preview and POST /api/apps/{name}/yml/apply as the mutation. Persist the plan, show changes/blockers to a human (or a policy check in CI), then queue the apply. Because plan is synchronous and read-only, it is safe to call on page loads, in health checks, and from agents.

Outcome-first job handling

apply returns an async job app-yml-apply. The result carries outcome (applied | unchanged | partial | blocked | invalid | no-file), plus applied, failed, failures, blockers, errors. Critically, the last four outcomes end the job as failed while still carrying the result. So:

  • Do not map job failed to an exception/alert. Branch on outcome.
  • Keep a switch on outcome with explicit handling: blocked/invalid → surface blockers/errors to the author; no-file → nothing to do (file was null); partial → some resources applied, failures lists the rest; unchanged → success, no diff.
  • Only transport/5xx/timeout is a real failure.

Auto-apply as a deliberate opt-in

POST /api/apps/{name}/yml/auto/enable and …/disable are synchronous and idempotent, returning {app, auto, sudoers, file}. Use them behind an explicit confirmation step in your UI/CLI — enabling means anyone who can commit to the repo controls that app's server configuration. Practical guardrails:

  • Gate the toggle to a narrower token (only yml-manage) or a specific role, and log who flipped it.
  • Check sudoers in the response to confirm the server-side plumbing is actually in place.
  • Pair with branch protection / required review on the repo — that is now your real authorisation boundary.
  • Remember auto-apply only fires on Git-webhook deploys (fixed in 5.6.4); manual deploys won't trigger it, so add a manual apply path for hotfix flows.

Token and ability scoping

  • Existing tokens silently lack yml-view/yml-manage — mint new ones at rollout time.
  • Two tokens is usually right: a read-only yml-view token for dashboards, admin panels and MCP read tools; a yml-manage token for the deploy pipeline and the apply/auto routes.
  • apply and both auto endpoints require yml-manage; the plan endpoint needs only yml-view.

CI/CD integration

Two viable shapes:

  1. Observe-only in CI: call plan after deploy, fail the build or post a PR comment when blockers is non-empty or in_sync is false.
  2. Apply in CI: plan → assert no blockers → apply (job) → poll until terminal → assert outcome in applied|unchanged. Keep the polling inside your pipeline step, with the yml-manage token scoped to a single environment.

Agents and MCP

MCP server 1.5.0 exposes 76 tools on a single tools/list page, including AppYmlShow (read-only), AppYmlApply (job) and AppYmlAuto (enabled). Pattern: let the agent call AppYmlShow freely to reason about drift, and require an explicit human confirmation before AppYmlApply/AppYmlAuto. Because the tool list still fits one page, you can load it eagerly without pagination handling.

Job result enrichment

1.35.0 fills a missing parsed app key in job results from the job's parameters. If you persist job results keyed by app, you can now rely on result.app being present even when the CLI text didn't echo it — handy for correlating the app-yml-apply job back to the request without a lookup table.

Gotchas and Tips

  • 503 ≠ 403 ≠ 500. 503 on yml routes means the server is below 5.6.4. A missing ability gives an authorisation error, not 503. Distinguish these in your error handling — one is "upgrade the server", the other is "mint a better token".
  • Failed jobs carry results. The most common integration bug here will be treating failed as "no payload". Check for a result object before throwing.
  • Don't confuse the four failure-ish fields. valid.errors (parse/semantic problems), blockers (apply refuses while any is listed), failures (per-resource failures after a partial apply) and the job-level errors mean different things and drive different UX.
  • file: null is normal. The plan reads the cipi.yml of the live release; a fresh app or one deployed before the file was added will return null and apply will report no-file. Don't treat it as a bug.
  • Idempotency is your friend. Auto enable/disable can be called repeatedly — reconcile desired state from config on every run rather than tracking flips in your own DB. auto in the response is the truth; sudoers tells you about the server-side grant.
  • Sudoers drift. If /etc/sudoers.d/cipi-api was hand-edited or the migration didn't run, yml plan *, yml apply *, yml auto * lines may be missing and the API will fail confusingly. Verify with the CLI on the host.
  • Debug at the CLI, not through HTTP. cipi yml plan <app> --json on the server is byte-for-byte what the endpoint reports. When the API response surprises you, run the CLI and compare — it collapses the whole client/server question in one step.
  • Custom commands must be whitelisted. Anything passed through CipiCliService only survives if it's in ALLOWED_COMMANDS; the release added the three yml verbs, so wrappers you wrote around them need no change, but new verbs do.
  • Extension points: config/cipi.php for abilities/endpoints, CipiCliService::ALLOWED_COMMANDS for CLI surface, and the OpenAPI doc for generating typed DTOs (YmlPlanResponse, YmlAutoResponse, JobResultAppYmlApply) instead of hand-mapping arrays.
  • Security posture to document in your app: with auto-apply on, the repo is the config source of truth for the server. Protect the default branch, review cipi.yml changes like infrastructure code, and keep the yml-manage token out of anything a repo contributor can read.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core