Skip to main content

Event Streaming

ZeroDB includes event streaming for real-time agent communication and application state tracking.

Create an Event

curl -X POST https://api.ainative.studio/api/v1/public/zerodb/events \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "agent.task_completed",
"data": {
"agent_id": "agent_123",
"task": "research",
"result": "Found 5 relevant papers"
}
}'

List Events

curl "https://api.ainative.studio/api/v1/public/zerodb/events?type=agent.task_completed&limit=20" \
-H "Authorization: Bearer $TOKEN"

Event Parameters

ParameterTypeRequiredDescription
typestringYesEvent type (e.g., agent.task_completed)
dataobjectYesEvent payload
sourcestringNoSource system or agent ID
correlation_idstringNoID for tracking related events across systems

Python SDK

import requests

headers = {"Authorization": "Bearer YOUR_API_KEY"}
base = "https://api.ainative.studio/api/v1/public/zerodb/events"

# Create an event
requests.post(base, headers=headers, json={
"type": "agent.task_completed",
"data": {
"agent_id": "agent_456",
"task": "research",
"duration_ms": 2340,
"result": "success"
},
"source": "agent-orchestrator",
"correlation_id": "workflow_789"
})

# Query events by type and time range
response = requests.get(base, headers=headers, params={
"type": "agent.task_completed",
"start_time": "2026-04-01T00:00:00Z",
"limit": 50
})
for event in response.json()["events"]:
print(f"[{event['timestamp']}] {event['type']}: {event['data']}")
ℹ️Correlation IDs

Use correlation IDs to track related events across distributed agent systems. Query all events with the same correlation_id to reconstruct the full workflow trace.

Use Cases

Agent Coordination

Agents publish events when tasks complete; other agents subscribe and react.

Audit Logging

Track all agent actions for compliance and debugging with full history.

State Sync

Keep frontend and backend state synchronized in real time.

Workflow Triggers

Use events to trigger downstream processes and automation.

Endpoints

MethodPathDescription
POST/zerodb/eventsCreate an event
GET/zerodb/eventsList events with filters
GET/zerodb/events/{id}Get a specific event