← All lessons/Real-Time
41
Real-Time

Global Broadcast Bus & Publications

Subscribe to all events across all agents, and publish cross-agent messages.

Prerequisite: Lesson 40 complete

What you'll learn

  • GET /v1/stream — all events from all agents
  • Each event includes agent_id for client-side filtering
  • POST /v1/publications — broadcast to a topic
  • GET /v1/publications/subscribe?topic=... — topic subscription
  • Use case: one global dashboard for all agents
Challenge

Open global SSE stream. Write records to 3 different agents. Confirm global stream shows all 3 with their agent_id values.

Interactive Walkthrough

What you'll learn

Subscribe to all events across all agents, and use the publications system for cross-agent messaging.

Global SSE stream

# All events from all agents
curl -N "http://localhost:7475/v1/stream" \
  -H "Authorization: Bearer spx_root_YOUR_ROOT_KEY"

Events include agent_id so you can filter client-side:

` event: record data: {"agent_id":"orders","content_hash":"...","payload":{"status":"paid"}}

event: record data: {"agent_id":"users","content_hash":"...","payload":{"plan":"enterprise"}} `

Publications — broadcast a message

curl -s -X POST http://localhost:7475/v1/publications \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \
  -d '{
    "topic":   "order.paid",
    "payload": {"order_id": "ord_001", "amount": 299.99}
  }' | python3 -m json.tool

All subscribers to order.paid receive the event instantly.

Subscribe to a topic

curl -N "http://localhost:7475/v1/publications/subscribe?topic=order.paid" \
  -H "Authorization: Bearer spx_root_YOUR_ROOT_KEY"

Challenge

Open a global SSE stream. Write records to 3 different agents. Confirm the global stream receives all 3 events with their respective agent_id values.

---

← Previous
Lesson 40: Per-Agent SSE Stream
Next →
Lesson 42: Epigenetic Profiles