---
title: "CLI, Schema & HTTP API"
description: "Complete fleet.schema.json field table, flarelensd CLI commands, GitHub Actions OIDC workflow, and Control Plane REST endpoints."
---

> Documentation Index
> Fetch the complete documentation index at: https://flarelens.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI, Schema & HTTP API

Canonical technical reference for declarative workload manifests, the `flarelensd` host daemon CLI, keyless GitHub Actions OIDC synchronization, and Control Plane HTTP endpoints.

## Declarative Manifest Schema (`fleet.schema.json`)

Add `# $schema: https://flarelens.dev/schemas/fleet.schema.json` at the top of YAML manifests (or `"$schema"` in JSON) for IDE autocompletion and validation.

| Field | Type | Description |
|---|---|---|
| `name` | `string` *(required)* | Logical service name (e.g. `checkout-api`, `postgres`). Resolved in MagicDNS as `<name>.<env>.mesh`. |
| `env` | `"dev" \| "uat" \| "prod"` | Environment isolation boundary for Vault secrets, revisions, and DNS zones. |
| `strategy` | `"blue_green" \| "singleton"` | Dual-slot zero-downtime swap for stateless apps, or single-instance stateful lifecycle. |
| `enabled` | `boolean` | Defaults to `true`. Set `false` to stage manifests in D1 as `Suspended` without starting containers. |
| `adopt_only` | `boolean` | Monitor and enforce cgroups on pre-existing host containers without recreating them. |
| `image` | `string` *(required)* | Full OCI image reference (tag or immutable `@sha256` digest). |
| `domain` / `domains` | `string` / `string[]` | Public HTTPS hostnames routed via Traefik `Host(...)` rules. |
| `internal_port` | `integer` | Container listening port probed and routed by Traefik and the WireGuard service router. |
| `health_path` | `string` | HTTP readiness path polled before atomic Blue/Green cutover (e.g. `/healthz`). |
| `placement` | `object` | `{ strategy: "spread" \| "binpack" \| "pinned", replicas: number, required_tags: string[], node_id?: string }`. |
| `resources` | `object` | Hard Linux kernel cgroup caps: `{ memory_mb: integer, cpu_cores: number }`. |
| `worker` | `object` | Optional companion worker container with dedicated `command[]` and `resources` override. |
| `jobs` | `JobSpec[]` | Scheduled UTC `CronJob`s (`schedule: "0 2 * * *"`) and on-demand one-off container commands (`concurrency_policy`, `timeout_seconds`, `memory_mb`, `cpu_cores`). |
| `backup` | `BackupSpec` | Declarative UTC `pg_dump` schedule and R2 retention policy (`{ schedule: "0 3 * * *", retain_days: 30, databases?: string[], prefix?: string }`). |
| `pre_deploy_snapshot` | `boolean` | Stream a gzipped `pg_dump` snapshot to R2 prior to running schema migrations. |
| `run_migrations` / `migration_command` | `boolean` / `string[]` | Execute a one-shot migration container before booting the candidate Blue/Green slot. |
| `env_vars` | `Record<string, string>` | Non-secret runtime environment variables merged with encrypted Vault secrets. |

## Host Agent CLI (`flarelensd`)

Daemon configuration is stored at `/etc/flarelens/agent.toml` with `0600` WireGuard key material under `/var/lib/flarelens/`.

```bash title="Common flarelensd host & workstation commands"
# Inspect daemon health and live reconciliation logs
sudo systemctl status flarelens-agent
sudo journalctl -u flarelens-agent -f

# Join, disconnect, or log out of the private WireGuard mesh from a laptop
sudo flarelensd login --control https://ops.example.com
sudo flarelensd down
sudo flarelensd logout

# Expose localhost:<port> on a temporary public HTTPS URL over WireGuard + Gateway Traefik
flarelensd http 3000 --subdomain my-preview
flarelensd http 8080 --subdomain webhook-test --auth user:pass

# Stream live container stdout/stderr without SSH (local Docker socket or remote Control Plane)
flarelensd logs checkout-api --env prod -f
flarelensd logs postgres --env uat --tail 250 --timestamps

# Cleanly unenroll a server or completely uninstall flarelensd (running Docker apps stay untouched)
sudo flarelensd leave --yes
sudo flarelensd uninstall --yes

# Print binary version & CLI help
flarelensd --version
flarelensd --help
```

## Keyless GitHub Actions OIDC Sync

Authorize your repository in the FlareLens console and sync declarative manifests via GitHub's native OIDC provider—zero static tokens stored in GitHub Secrets:

```yaml title=".github/workflows/fleet-sync.yml"
name: Sync Fleet Manifests
on:
  push:
    branches: [main]
    paths: ["fleet/**"]

permissions:
  id-token: write
  contents: read

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Exchange GitHub OIDC & Sync Fleet
        run: |
          OIDC_TOKEN=$(curl -sLS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
            "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=flarelens" | jq -r .value)
          jq -s '{ manifests: . }' fleet/prod/*.json | \
            curl -fsSL -X POST https://ops.example.com/api/v1/control/fleet/sync \
              -H "Authorization: Bearer $OIDC_TOKEN" \
              -H "Content-Type: application/json" \
              -d @-
```

## Control Plane HTTP Endpoints

| Endpoint | Auth | Purpose |
|---|---|---|
| `POST /api/v1/ingest` | `INGEST_SECRET` | 15s host heartbeat; returns piggybacked `commands`, `mesh_peers`, `cluster_endpoints`, and `flags_version`. |
| `POST /api/v1/control/fleet/sync` | Bearer / GitHub OIDC | Validate and commit declarative manifests into an immutable `rev-N` snapshot. |
| `POST /api/v1/control/fleet/promote` | Operator / API Token | Promote verified service digests and config across environments (`uat → prod`). |
| `POST /api/v1/control/fleet/rollback` | Operator / API Token | Restore fleet desired state to any historical `rev-N` snapshot in D1 + R2. |
| `POST /api/v1/control/nodes/:id/drain` | Operator / API Token | Cordon host, reschedule stateless replicas, and fence local `singleton` volumes. |
| `POST /api/v1/control/nodes/:id/uncordon` | Operator / API Token | Return a drained host back to active placement scheduling. |
| `POST /api/v1/control/nodes/:id/leave` | Agent / Operator Token | Drain stateless replicas, fence stateful volumes, and unenroll node + mesh peer from D1. |
| `POST /api/v1/control/mesh/leave` | Agent Token / Ed25519 Proof | Deregister a server or SSO workstation peer from the WireGuard mesh. |
| `POST /api/v1/control/nodes/:id/prune-images` | Operator / API Token | Queue two-pass Docker image garbage collection (dangling `>24h`, unused `>72h`). |
| `GET /api/v1/control/jobs` | Operator / API Token | List declared manifest jobs (with `next_run_at`) and recent D1 `job_runs` history. |
| `POST /api/v1/control/jobs/run` | Operator / API Token | Queue a declared manifest job or ad-hoc ephemeral container command (`run_job`). |
| `POST /api/v1/control/jobs/status` | Agent Token | Host daemon callback reporting job `running` / `succeeded` / `failed` / `timed_out`, `exit_code`, and output logs. |
| `GET /api/v1/control/tunnels` | Operator / API Token | List active public HTTPS localhost funnel tunnels (`flarelensd http`). |
| `POST /api/v1/control/tunnels` | Token / Ed25519 Proof | Register an ephemeral `100.64.0.0/10` WireGuard funnel tunnel and queue `sync_tunnel` on the gateway node. |
| `DELETE /api/v1/control/tunnels/:id` | Token / Ed25519 Proof | Revoke a funnel tunnel lease and queue `remove_tunnel` on the gateway node. |
| `POST /api/v1/control/containers/logs/sessions` | Token / Ed25519 Proof | Open a zero-SSH live container stdout/stderr log session (`stream_container_logs`). |
| `GET /api/v1/control/containers/logs/sessions/:id` | Token / Ed25519 Proof | Poll incremental demultiplexed container log chunks (`?after=<seq>`). |
| `POST /api/v1/control/agent/releases` | Operator / API Token | Publish SHA-256 verified `flarelensd` binary release for zero-SSH OTA rollouts. |

Source: https://flarelens.dev/docs/reference/index.mdx
