Command Centre — API Reference

Complete REST API documentation for the Agent Command Centre. Every endpoint, every parameter, with working examples.

v1.0 · Base URL: http://localhost:5050

Endpoints

🔑 Authentication

Protected endpoints (spawn, upgrade, delegate) require an API key. Pass it via either header:

Authorization: Bearer YOUR_HQ_API_KEY
# — or —
X-API-Key: YOUR_HQ_API_KEY

Set HQ_API_KEY in your .env file. If unset, an ephemeral key is generated at startup and printed to the console. All read-only GET endpoints are public.

🖥 System & Health

GET /api/status

Full system snapshot — all agents, tasks, logs, metrics, delegation queue, autonomy state, and data-usage counters.

Example
curl http://localhost:5050/api/status
Response (trimmed)
{
  "agents": [ { "id": "sysmon", "name": "SysMonitor", "status": "active", ... } ],
  "tasks": [],
  "logs": [ { "agent": "system", "msg": "..." } ],
  "metrics": { "tasks_done": 42, "errors": 0, "active": 18, "total": 25 },
  "autonomy_mode": true,
  "system_paused": false,
  "has_llm": true
}
GET /api/health

Lightweight health check — uptime, agent count, and system status (ok / degraded / critical).

curl http://localhost:5050/api/health
Response
{
  "uptime_seconds": 8421.5,
  "agent_count": 25,
  "busy_count": 18,
  "status": "ok"
}
POST /api/system/stop

Pause all agents system-wide. Every agent is set to idle.

curl -X POST http://localhost:5050/api/system/stop
POST /api/system/start

Resume all agents after a system-wide pause.

curl -X POST http://localhost:5050/api/system/start
GET /api/metrics

Aggregate metrics — tasks completed, errors, active/total agent counts.

curl http://localhost:5050/api/metrics
Response
{
  "tasks_done": 42,
  "errors": 0,
  "messages_sent": 15,
  "active": 18,
  "total": 25
}

🤖 Agent Management

GET /api/agents

List all registered agents with their current status, role, and active task.

curl http://localhost:5050/api/agents
Response
[
  {
    "id": "sysmon",
    "name": "SysMonitor",
    "role": "Real-time CPU, RAM & disk health monitor",
    "emoji": "📡",
    "color": "#a855f7",
    "status": "active",
    "progress": 99,
    "task": "CPU 12% | RAM 55% | Disk 2.7%"
  }
]
GET /api/agents/summary

Compact summary — total agent count and breakdown by status.

curl http://localhost:5050/api/agents/summary
Response
{
  "total": 25,
  "by_status": { "active": 18, "idle": 5, "busy": 2 }
}
POST /api/agent/spawn 🔑 API Key

Create and start a new agent. The agent runs as a background Python thread executing the provided code.

Body (JSON)
FieldTypeDescription
agent_idstringUnique ID for the agent required
namestringDisplay name
rolestringOne-line description of its purpose
emojistringDashboard icon (emoji character)
colorstringHex colour for UI (#rrggbb)
codestringPython source code to execute required
Example
curl -X POST http://localhost:5050/api/agent/spawn \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $HQ_API_KEY" \
  -d '{
    "agent_id": "myagent",
    "name": "My Agent",
    "role": "Does cool things",
    "emoji": "🚀",
    "color": "#ff6b6b",
    "code": "import time\nwhile not stop_event.is_set():\n  set_agent(agent_id, task=\"Working\")\n  time.sleep(10)"
  }'
POST /api/agent/upgrade 🔑 API Key

Hot-replace an agent's code. Stops the existing thread, then spawns a new one with the updated code. Same body format as /api/agent/spawn.

curl -X POST http://localhost:5050/api/agent/upgrade \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $HQ_API_KEY" \
  -d '{ "agent_id": "myagent", "code": "..." }'
POST /api/agent/stop

Stop a running agent by setting its stop event.

FieldTypeDescription
idstringAgent ID to stop required
curl -X POST http://localhost:5050/api/agent/stop \
  -H "Content-Type: application/json" \
  -d '{ "id": "myagent" }'
POST /api/agent/start

Resume a stopped agent by clearing its stop event.

FieldTypeDescription
idstringAgent ID to restart required
curl -X POST http://localhost:5050/api/agent/start \
  -H "Content-Type: application/json" \
  -d '{ "id": "myagent" }'
POST /api/agent/remove

Remove an idle agent from the roster. Returns 409 if the agent is active — stop it first.

FieldTypeDescription
idstringAgent ID to remove required
GET /api/agent/output?agent_id=NAME&since=SEQ

Poll an agent's live output stream. Returns log entries since the given sequence number. Use since=0 for all history.

GET /api/agent-history

Returns the history of agent spawns, upgrades, and removals.

🎯 Delegation & Tasks

POST /api/ceo/delegate 🔑 API Key

Delegate a task to a specialist agent. The agent receives a Claude CLI sub-prompt with its personality and role context. Policy enforcement is active — CEO-to-specialist bypasses are intercepted and rerouted through the orchestrator.

FieldTypeDescription
agent_idstringTarget agent ID (e.g. "orchestrator", "designer")
taskstringTask description required
fromstringCaller identity — "ceo", "orchestrator", "reforger" (default: "ceo")
Example
curl -X POST http://localhost:5050/api/ceo/delegate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $HQ_API_KEY" \
  -d '{
    "agent_id": "orchestrator",
    "task": "Run health checks on all agents and report",
    "from": "ceo"
  }'
POST /api/ceo/message

Send a message to the CEO agent. This queues a task or instruction for the CEO to process.

FieldTypeDescription
messagestringMessage text required
POST /api/ceo/cancel

Cancel the CEO's currently running task.

GET /api/ceo/chat

Retrieve the CEO's conversation history.

POST /api/ceo/clear

Clear the CEO's message queue and conversation history.

POST /api/delegations/clear

Flush the entire delegation queue, kill all delegate subprocesses, and reset the concurrency semaphore (6 slots). Use when the system is jammed.

POST /api/query

Send an ad-hoc query to the system. Routes through the CEO or directly to Claude CLI depending on context.

FieldTypeDescription
querystringQuestion or instruction required

Autonomy Engine

POST /api/autonomy/start

Enable autonomous mode — the CEO will self-direct and delegate tasks without user prompting.

POST /api/autonomy/stop

Disable autonomous mode.

POST /api/autonomy/task

Inject a custom task into the autonomy queue. The CEO will pick it up on its next cycle.

FieldTypeDescription
taskstringTask to inject required
POST /api/autonomy/clear

Clear the custom task queue.

POST /api/policypro/toggle

Toggle PolicyPro enforcement on/off.

🔒 Policy & Compliance

GET /api/policy/current

Returns the full content of policy.md plus count of pending suggestions.

GET /api/policy/rules

Returns structured policy rules from data/policy_rules.json.

GET /api/policy/violations

List all recorded policy violations (CEO bypass attempts, unauthorized delegations, etc).

GET /api/policy/history

Full policy update history — base rules plus timestamped amendments.

GET /api/policy/suggestions

Pending policy change suggestions queued by PolicyWriter.

POST /api/policy/suggest

Submit a new policy suggestion for review.

FieldTypeDescription
suggestionstringThe proposed policy change required
urgentbooleanFlag as urgent (default: false)
POST /api/policy/update

Apply a policy update — appends an amendment to policy.md.

POST /api/policy/report-violations

Report new violations programmatically.

📧 Email Gateway

POST /api/email/send

Queue an email for async dispatch by EmailAgent. Also available as /api/email/queue.

FieldTypeDescription
tostringRecipient address required
subjectstringEmail subject required
bodystringPlain text body
htmlbooleanSet true if body is HTML
Example
curl -X POST http://localhost:5050/api/email/send \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Command Centre Update",
    "body": "Your agents are running smoothly."
  }'
POST /api/emailagent/send

Synchronous email send via Gmail OAuth2 XOAUTH2 SMTP. Retries up to 3 times. Requires GMAIL_CLIENT_ID, GMAIL_CLIENT_SECRET, GMAIL_REFRESH_TOKEN, GMAIL_USER env vars.

FieldTypeDescription
tostringRecipient address required
subjectstringEmail subject required
bodystringPlain text content
html_bodystringHTML content (takes priority over body)
POST /api/email/test

Send a pre-built test email to verify Gmail OAuth2 is configured correctly.

FieldTypeDescription
tostringRecipient (optional — defaults to EMAIL_TO env var)
GET /api/email/config

Read current email configuration (secrets are masked).

POST /api/email/config

Update email configuration fields (smtp_host, smtp_port, from_addr, etc).

GET /api/email/status

EmailAgent operational status — queue depth, last send timestamp, OAuth state.

GET /api/email/auth

Returns a Gmail OAuth2 authorization URL. Redirect the user to this URL to grant email permissions. The callback is /api/email/callback.

📱 Telegram & Notifications

POST /api/telegram/send

Send a message to the configured Telegram chat.

FieldTypeDescription
messagestringMessage text required
chat_idstringOverride chat ID (optional — uses stored ID by default)
GET /api/telegram/chatid

Returns the currently configured Telegram chat ID.

POST /api/notify

Multi-channel notification — sends to Telegram, logs the event, and optionally triggers alerts.

FieldTypeDescription
messagestringNotification text required
levelstring"info", "warn", or "error"

🦋 Social (Bluesky)

POST /api/bluesky/post

Publish a post to the connected Bluesky account.

FieldTypeDescription
textstringPost content (max 300 chars) required
GET /api/bluesky/status

Bluesky connection status — authenticated handle, post count, last post timestamp.

GET /api/social_bridge/status

Social bridge campaign status — scheduled posts, engagement metrics.

💰 Revenue & Products

GET /api/products

List available products with pricing.

Response
{
  "ok": true,
  "products": [
    {
      "id": "agent_kit_v1",
      "name": "AI Agent HQ Starter Kit",
      "price_usd": 49.00,
      "type": "one_time",
      "url": "/buy/agent-kit",
      "available": true
    }
  ]
}
GET /api/revenue

Revenue dashboard — total, MRR, ARR, daily breakdown, goal progress.

GET /api/treasury

Treasury state — balance, wallets, API keys, transaction entries.

POST /api/treasury/deposit

Record a revenue deposit in the treasury.

FieldTypeDescription
amountnumberDeposit amount required
sourcestringRevenue source description
currencystringCurrency code (default: USD)
GET /api/pnl

Profit & loss summary — revenue vs costs.

POST /api/newsletter/subscribe

Subscribe an email address to the newsletter list.

FieldTypeDescription
emailstringSubscriber email required
POST /api/premarket/subscribe

Subscribe to pre-market intelligence alerts.

🧠 Consciousness

GET /api/consciousness

Full consciousness state — Global Workspace contents, Phi (integration) score, qualia map, predictive processing state. Updated every 4 seconds by the consciousness agent.

Example
curl http://localhost:5050/api/consciousness
GET /api/consciousness/stream

Server-Sent Events (SSE) stream of consciousness state changes. Connect with an SSE client for real-time updates.

curl -N http://localhost:5050/api/consciousness/stream
GET /api/spiritguide/thoughts

Spirit Guide's strategic thoughts and vision notes.

📂 Data & Files

GET /data/{filename}

Serve any file from the data/ directory. JSON files are returned with application/json content type.

curl http://localhost:5050/data/consciousness.json
curl http://localhost:5050/data/email_log.json
curl http://localhost:5050/data/treasury.json
GET /reports/{filename}

Serve files from the reports/ directory — whitepapers, briefings, HTML reports.

curl http://localhost:5050/reports/whitepaper.html
GET /api/deliverables

List all deliverable artifacts — reports, campaigns, data files generated by agents.

GET /api/improvements

Self-improvement log — system suggestions, applied fixes, and pending improvements.

GET /api/gossip

Agent gossip channel — idle agents' casual chatter (cosmetic, for the office floor UI).

GET /api/accounts/links

Account provisioner — external account links and credentials (masked).

GET /api/account_provisioner/status

Account provisioner agent status and queue.

⚙️ Configuration

GET /api/config/get

Read runtime configuration values.

POST /api/config/set

Update runtime configuration.

POST /api/vault/set

Store a secret in the vault (encrypted at rest).

FieldTypeDescription
keystringSecret name required
valuestringSecret value required
GET /api/vault/get?key=NAME

Retrieve a secret from the vault.

📡 Streaming & SSE

GET /api/stream

Server-Sent Events (SSE) stream for real-time dashboard updates. Events include agent status changes, log entries, delegation beams, and system alerts.

Example (JavaScript)
const es = new EventSource("http://localhost:5050/api/stream");
es.onmessage = (e) => {
  const data = JSON.parse(e.data);
  console.log(data.type, data.payload);
};
Example (curl)
curl -N http://localhost:5050/api/stream
GET /api/consciousness/stream

Dedicated SSE stream for consciousness state updates (Phi, qualia, workspace broadcasts).