---
title: "Event Streaming"
description: "Real-time event streams for agent workflows and application state"
canonical: "https://docs.ainative.studio/docs/zerodb/events"
last-updated: "2026-10-03T21:47:10.764Z"
---

# Event Streaming

Source: https://docs.ainative.studio/docs/zerodb/events

> Real-time event streams for agent workflows and application state

## Event Streaming

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

## Create an Event

```bash
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

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

## Event Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `type` | `string` | Yes | Event type (e.g., `agent.task_completed`) |
| `data` | `object` | Yes | Event payload |
| `source` | `string` | No | Source system or agent ID |
| `correlation_id` | `string` | No | ID for tracking related events across systems |

## Python SDK

```python
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']}")
```

<Callout type="info" title="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.
</Callout>

## Use Cases

<CardGrid cols={2}>
  <FeatureCard title="Agent Coordination">Agents publish events when tasks complete; other agents subscribe and react.</FeatureCard>
  <FeatureCard title="Audit Logging">Track all agent actions for compliance and debugging with full history.</FeatureCard>
  <FeatureCard title="State Sync">Keep frontend and backend state synchronized in real time.</FeatureCard>
  <FeatureCard title="Workflow Triggers">Use events to trigger downstream processes and automation.</FeatureCard>
</CardGrid>

## Endpoints

| Method | Path | Description |
|--------|------|-------------|
| POST | `/zerodb/events` | Create an event |
| GET | `/zerodb/events` | List events with filters |
| GET | `/zerodb/events/{id}` | Get a specific event |
