REST API
moira is the usual client, but the API is plain HTTPS and JSON, so scripts can use it too.
The source of truth is api/openapi.yaml (OpenAPI 3.1) in the repository.
Conventions
Section titled “Conventions”- Base URL:
https://<host>:7443. All routes are under/v1. - Auth:
Authorization: Bearer moira_…on every route exceptPOST /v1/enroll. Use the token from your client config, and pin the certificate fingerprint (moirad tls fingerprint) rather than disabling verification. - JSON bodies use camelCase fields, RFC 3339 UTC timestamps, and
nullfor unknown values. - Streams are
application/x-ndjson: one JSON object per line, flushed per line. - Stack names match
^[a-z0-9][a-z0-9._-]*$. Service and container names match^[a-zA-Z0-9][a-zA-Z0-9_.-]*$.
With cert.pem copied from <state dir>/tls/cert.pem on the host:
curl --cacert cert.pem -H "Authorization: Bearer $TOKEN" https://192.0.2.10:7443/v1/infoErrors
Section titled “Errors”{ "error": { "code": "stack_locked", "message": "stack shop is busy with job k3f9x2", "jobId": "k3f9x2" } }| HTTP | code |
|---|---|
| 400 | bad_request |
| 401 | unauthorized: missing, unknown or revoked token |
| 403 | invite_invalid (enrollment only) |
| 404 | not_found |
| 409 | stack_locked, unmanaged |
| 412 | etag_mismatch |
| 428 | precondition_required |
| 429 | rate_limited |
| 500 | internal, docker_unavailable |
Enrollment and info
Section titled “Enrollment and info”POST /v1/enroll unauthenticated → { "secret": "…", "clientName": "laptop" } ← 200 { "token": "moira_…", "host": "edge", "client": "laptop", "api": 1 }
GET /v1/info ← { "host": "edge", "api": 1, "version": "v0.3.0", "compose": "5.8.0", "docker": "29.1.0", "deployDir": "/srv/deploy", "client": "laptop" }Clients refuse a server whose api major differs from their own.
Containers and stacks
Section titled “Containers and stacks”GET /v1/containers?unmanaged=true ← { "containers": [Container, …], "warnings": [ … ] }
GET /v1/stacks/{stack} ← { "stack": "shop", "dir": "/srv/deploy/shop", "composeName": "shop", "services": [Container, …], "envFiles": [ { "file": "prod.env", "services": ["shop-prod"] } ], "compose": "<raw Compose file>", "runbook": "<RUNBOOK.md or null>", "warnings": [] }A container:
{ "name": "shop-prod", "id": "3f2a9c…", "managed": true, "oneOff": false, "stack": "shop", "service": "shop-prod", "state": "running", "health": "healthy", "status": "Up 30 hours", "image": "ghcr.io/example/shop:stable", "imageId": "sha256:…", "createdAt": "2026-11-21T10:02:11Z", "startedAt": "2026-11-21T10:02:12Z", "restartCount": 0, "drift": { "config": false, "image": true }, "lockedBy": null}state:running,restarting,paused,exited,created,dead, ormissing(a service with no container; runtime fields arenull).health:healthy,unhealthy,starting, ornullwithout a healthcheck.driftisnullfor unmanaged containers, one-offs and missing services.- Unmanaged containers are left out unless
unmanaged=true.
Actions and jobs
Section titled “Actions and jobs”POST /v1/stacks/{stack}/services/{service}/{action} update | apply | start | stop | restartPOST /v1/stacks/{stack}/{action} whole stack, same actionsPOST /v1/containers/{name}/{action} unmanaged only: start | stop | restart ← 202 { "job": Job } | 409 stack_locked | 409 unmanagedA job:
{ "id": "k3f9x2", "action": "update", "stack": "shop", "services": ["shop-prod"], "container": null, "state": "running", "client": "laptop", "startedAt": "2026-11-22T14:00:00Z", "finishedAt": null, "exitCode": null}state is running, succeeded, failed or handed-off (see
Self-update). Jobs on unmanaged containers have stack: null,
services: [] and the container name in container.
GET /v1/jobs ← { "jobs": [Job, …] } newest first, last 50GET /v1/jobs/{id} ← { "job": Job }GET /v1/jobs/{id}/stream ← NDJSON: buffered output, then live output, then the final job {"type":"line","t":"2026-11-22T14:00:01Z","stream":"stdout","line":"→ pull"} {"type":"end","job":{…}}GET /v1/containers/{name}/logs?tail=200&since=1h&until=…&follow=true×tamps=true ← NDJSON: {"t":"2026-11-22T14:00:01.123Z","stream":"stdout","line":"listening on :3000"}sinceanduntiltake a duration (15m,1h) or an RFC 3339 time.taildefaults to 200, is capped at 10000, and acceptsallonly together withsince.tisnullunlesstimestamps=true.- There is no server-side filtering.
Env files
Section titled “Env files”GET /v1/stacks/{stack}/env/{file} ← { "file": "prod.env", "content": "…", "etag": "\"sha256:…\"", "mode": "0600", "services": ["shop-prod"] }
PUT /v1/stacks/{stack}/env/{file} If-Match: "sha256:…" → { "content": "…" } ← { "etag": "\"sha256:…\"", "backup": ".history/prod.env.20261122T140000Z", "services": ["shop-prod"] } | 412 etag_mismatch | 428 precondition_required
GET /v1/stacks/{stack}/env/{file}/history ← { "entries": [ { "id": "20261122T140000Z", "kind": "history", "time": "…" }, { "id": "bak-cutover", "kind": "bak", "time": "…" } ] }
GET /v1/stacks/{stack}/env/{file}/history/{id} ← { "content": "…" }PUTrequiresIf-Matchwith the ETag from your read. A changed file returns412with the current ETag when available.- Content is limited to 1 MiB of UTF-8.
- To restore, read a history entry and
PUTits content. The restore gets its own backup.
Limits
Section titled “Limits”| What | Limit |
|---|---|
| Log streams | 64 per daemon, 8 per client |
| Job streams | 64 per daemon, 8 per client |
| Job output | 2000 lines and 512 KiB per job; lines over 4 KiB truncated |
| Retained jobs | 50 |
| Enrollment | 8 concurrent; 5 failures per minute per source address |