The Papercup org backend is a Hono module mounted at /api/org. ~50 endpoints, all file-backed (no DB).
| Endpoint | Purpose |
|---|
GET /charter | Read the current charter markdown |
PUT /charter | Replace the charter (≥100 chars; emits audit entry) |
| Endpoint | Purpose |
|---|
GET /departments | All 5 with live counts, autoLoop status, scheduler info, active run |
GET /:dept | Single dept with recent inbox/outbox previews |
GET /:dept/inbox / outbox | Materialized view contents |
GET /:dept/notes / PUT /:dept/notes | Director notes (markdown) |
GET /:dept/decisions | Decision log markdown |
GET /:dept/director-config / PUT /:dept/director-config | Auto-loop config (persisted) |
| Endpoint | Purpose |
|---|
GET /messages?from=&to=&projectId=&kind=&status=&q= | Filtered list |
POST /messages | Send (charter-validated; auto-defaults projectId) |
GET /messages/:id | Detail with referenced and responses |
PATCH /messages/:id/status | Single status transition |
POST /messages/bulk-status | Update many at once |
GET /messages/:id/comments / POST | Operator notes on a message |
| Endpoint | Purpose |
|---|
GET /projects?vertical= | Filtered list |
POST /projects | Create (auto-emits ProjectKickoff broadcast) |
GET /projects/:slug | Detail with recent activity |
PATCH /projects/:slug | Update fields |
DELETE /projects/:slug | Hard delete (rejects reserved; relinks messages → org-ops) |
GET /projects/:slug/timeline | Messages where projectId matches |
GET /projects/:slug/capabilities | Filtered to kind=Capability |
GET /projects/:slug/spinouts | Filtered to kind=ProjectSpinout |
GET /projects/:slug/campaigns | Filtered to kind=Campaign |
| Endpoint | Purpose |
|---|
GET /directives?status= | Filtered list |
POST /directives | Create + auto-emit Directive message to Business |
GET /directives/:id | Detail with summaries + linked messages |
PATCH /directives/:id | Update fields |
DELETE /directives/:id | Soft-cancel (status=‘cancelled’) |
GET /directives/:id/summaries / POST | CEO or user summary log |
GET /directives/:id/timeline | Messages where directiveId matches |
POST /directives/:id/projects | Spin up another project (1:N) |
POST /directives/:id/route | Back-compat: creates first project |
| Endpoint | Purpose |
|---|
GET /:dept/prompt?role=&mode=&context=1 | Resolved prompt with optional live state |
POST /:dept/run-director | One-shot orchestrator decision (no execution) |
POST /:dept/run-loop | Full autonomous loop (orchestrator → worker → execute) |
GET /:dept/run-director-stream | SSE-streamed run output |
POST /:dept/stop-loop | Cancel active run |
GET /:dept/director-runs / /:dept/director-runs/:filename | Past run records |
GET /:dept/director-stats | Per-dept KPI rollup |
GET /active-runs | All in-flight runs across departments |
GET /schedulers | Server-side timers with secondsRemaining |
GET /all-director-stats | Cross-org KPI aggregation |
| Endpoint | Purpose |
|---|
GET /search?q= | Universal — messages + directives + projects |
| Endpoint | Purpose |
|---|
GET /audit?subject=&action=&limit= | Audit log for charter/config/admin changes |
| Endpoint | Purpose |
|---|
POST /admin/rebuild-views | Rebuild materialized inbox/outbox files |
POST /admin/stop-all | Emergency stop — cancel runs + clear schedulers + persist autoLoop=false |
POST /admin/archive-acknowledged?olderThanMs= | Sweep acknowledged messages older than N ms (default 30d) |
Some message kinds trigger automatic state mutations (no separate API call needed):
Capability (from technology) — increments capabilitiesAvailable on every active non-reserved project
CapabilityDeprecation (from technology) — decrements counter; appends to deprecatedCapabilities[]
BudgetAllocation (with projectId + metadata.amount_cents) — accumulates into budget_cents
ProgressUpdate (from management, with metadata.statusUpdate) — advances project status
Charter validation always runs server-side, so a worker that emits something illegal fails the loop iteration rather than corrupting state.