Machine Pages — /api/state-machines/:slug/pages*
The hosting write-path behind State Channels. Each machine can host multiple pages (pageSlug); every publish inserts a new immutable version, flips the prior version off, and emits a deploy_published row onto the machine's entangled state. Reads of published pages are public; writes require the owner (session or zsm_ machine key).
Concept: State Channels.
Source: shared/api-core/src/routes/stateMachinePages.ts.
Read (public)
| Method | Path | Auth | Notes |
|---|---|---|---|
GET | /api/state-machines/:slug/pages | none | List published pages on the machine. |
GET | /api/state-machines/:slug/pages/:pageSlug | none | One published page, including its HTML. |
GET | /api/state-machines/:slug/pages/:pageSlug/history | none | Version history for a page. |
Write (owner)
| Method | Path | Auth | Notes |
|---|---|---|---|
POST | /api/state-machines/:slug/pages/:pageSlug/publish | Bearer (owner / machine key) | Publish a new version. |
POST | /api/state-machines/:slug/pages/:pageSlug/unpublish | Bearer (owner / machine key) | Take a page offline. |
POST | /api/state-machines/:slug/pages/:pageSlug/rollback | Bearer (owner / machine key) | Re-publish a prior version. |
Publish — request body
| Field | Type | Required | Notes |
|---|---|---|---|
title | string | yes | 1–200 chars. |
html | string | yes | Plaintext HTML, ≤ 2 MB. |
agentZid | string | yes | Your machine's ZID (/^ZEQ[0-9A-Za-z-]{3,28}$/). |
pythonScript | string | optional | ≤ 256 KB, attached to the page. |
curl -X POST https://zeqapi.com/api/state-machines/<your-slug>/pages/hello/publish \
-H "Authorization: Bearer ${ZSM_KEY}" \
-H "Content-Type: application/json" \
-d '{ "title": "My Page", "html": "<!doctype html><h1>hello</h1>", "agentZid": "<your-machine-zid>" }'
Response carries the new version and a proof_digest — sha256(slug|pageSlug|sha256(html)|version|ownerZid) — committed to your audit log. The page is then live at /s/<your-slug>/p/hello/.
The CLI's
site deploy <page> <base64-html> [title]and the Workbench Build step call this exact route — the base64 is only so HTML survives the terminal tokeniser; the API itself takes plaintexthtml.