Skip to main content

Event Streaming

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/{project_id}/database/events \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"topic": "agent.task_completed",
"event_payload": {
"agent_id": "agent_123",
"task": "research",
"result": "Found 5 relevant papers"
}
}'

List Events​

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

Event Parameters​

ParameterTypeRequiredDescription
topicstringYesEvent topic (e.g., agent.task_completed)
event_payloadobjectYesEvent payload

Python SDK​

import requests

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

## Create an event
requests.post(base, headers=headers, json={
"topic": "agent.task_completed",
"event_payload": {
"agent_id": "agent_456",
"task": "research",
"duration_ms": 2340,
"result": "success"
}
})

## Query events by topic
response = requests.get(base, headers=headers, params={
"topic": "agent.task_completed",
"limit": 50
})
for event in response.json()["events"]:
print(f"[{event['published_at']}] {event['topic']}: {event['event_payload']}")

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​

All paths below are relative to /api/v1/public/zerodb/{project_id}.

MethodPathDescription
POST/database/eventsCreate an event
GET/database/eventsList events (filter by topic, paginate with skip/limit)
GET/database/events/{event_id}Get a specific event
POST/database/events/batchCreate multiple events at once
GET/database/events/statsAggregate event statistics
GET / POST/database/events/subscriptionsList / create event subscriptions
DELETE/database/events/subscriptions/{subscription_id}Remove a subscription